Integrating Cocoapods with large existing Xcode Workspace - xcode

I have recently been working with Cocoapods on my own projects, and would like to incorporate a couple of pods into a project at work. The problem is that our code consists of close to 20 projects stored inside a large workspace, sorted into folders. The structure of the projects is
Workspace
Apps (Folder)
Project 1
Project 2
etc...
Modules
More Projects
etc
Base Components
Even More Projects
etc
I am unsure how to write a podfile that would link a pod (RETableView in this case) against an app without disturbing the existing structure of the workspace? Is this even possible? If it isn't possible to incorporate cocoapods without changing the existing workspace, is it possible to set up cocoapods to compile pods as standalone libraries that I could incorporate into our project?

With CocoaPods 1.x you can use :integrate_targets => false in your Podfile like this:
install! :integrate_targets => false
You can find the documentation for this here
Previously (for older CocoaPods versions):
After creating your Podfile use pod install --no-integrate documented here. This will create the Pods project that you can then include in your workspace. Please make sure everything in your project is checked into your version control system first just in case anything goes wrong.

Related

How to temporarily disable frameworks added through POD file in Xcode

I'm using cocoapods in xcode for few frameworks (Firebase extensions, fabric, facebook sdk etc). The moment I generated the workspace, it take too long to compile and makes it very difficult to work on the project.
I'm looking for a solution where I can temporarily disable the frameworks that are added through pod.
I have been trying few ideas but all of them have their drawbacks.
1) Remove the pods and update the repo (but it has to download all the pods again)
2) Make a backup of pod folder and create a temporary pod file with very limited frameworks (Pod always try to download the selected frameworks even if they're present in the folder)
3) Remove the frameworks from dependencies (This still compile the frameworks as they're added as a separate project in the workspace)

GitHub, CocoaPods, and XCode

I have an iOS project which uses a few CocoaPods that I have been regularly committing to a private GitHub repo. Because of the CocoaPods, I always launch it via its workspace.
For the first time ever I attempted to work on the project on a different computer. When I opened XCode and attempted to pull the repo, I realized that the workspace is not in the repo. Only the project itself is there.
Does that mean I did something wrong when I initially created the project repository or does it mean that you simply cannot use multiple computers with GitHub to work on a project that requires CocoaPods?
Just run pod install on the other computer and it will download the dependencies from your Podfile.lock (or Podfile if no lock is present) and generate the workspace.
Another option is to add your Pods directory, along with your xcworkspace and Podfile.lock, to version control. That way your project will be always ready after cloning and your dependencies will be synced in your repository. If those items do not show up on Xcode's git interface, use the git from your Terminal or other app.
The use case you describe is quite common and works fine. You must have forgotten to add the workspace to the repo, maybe it’s in your .gitignores?

Removing frameworks from Xcode project now that they are being managed by Cocoapods

I just added Cocoapods to my xcode project. I followed all of the instructions, and all of my frameworks were installed perfectly. However, now I have duplicates. I have frameworks in my Pods directory, and these same frameworks are still in my project's Frameworks group.
What would be the proper way to go about removing these duplicates? Should I remove them from the Frameworks group? Should I remove the Frameworks group altogether?
If I do remove them, how can I properly link to the new ones in the Pods directory so that the compiler knows where their new location is?
Also, if I do remove the duplicates, will this create conflicts when trying to commit these changes to my project's GitHub repo?

Pod file in framework

We are working on many projects having common basic functionality, so we decided to put the common functionality in a framework and use it as git submodule, All well and good.
Now, I want to control Pods from framework as well, so I tried to put the Podfile into framework.
As Podfile and .xcodeproj are not in same directory, so to link the xcodeproj I tried to put
xcodeproj '../XYZ.xcodeproj'
As XYZ is different for every project, so want to use something like this.
xcodeproj '../*.xcodeproj'
Is there any way I can do it?
BTW it may be possible if I create a Private Pod and then use the Pods as dependencies of it, But in my case above solution will be handy.

Xcode Static libraries building in wrong folder

I've setup cocoapods for my project and I've been doing development for quite some time without any issues. Recently I added a new Configuration for it called "Beta", duplicating the "Release" configuration. At the same time, I added a Scheme that would build targets using this configuration.
This new scheme would build everything without issues, but linking would fail with the (quite known it seems) message:
ld: library not found for -lPods
I know that issues that makes this error message come up have been discussed widely around the web, with different causes and conditions:
library not found for -lPods
https://github.com/CocoaPods/CocoaPods/issues/155
None of these fixes seem to apply here. What I can see by looking into the workspace folder, is that Cocoapods build products are put in Build/Products/Release-iphonesimulator instead of in Build/Products/Beta-iphonesimulator, even though the app itself is built rightly so into the latter. Moving all the *.a files into Build/Products/Beta-iphonesimulator makes running in the simulator work properly, but the next build is still put in the wrong location.
Edit
After some further investigations, the environment variable $BUILT_PRODUCTS_DIR is set correctly in the build phase for the app itself, but not when building cocoapods products.
What causes this and how can I fix this?
Ruled out issues
pod install has been run, multiple times
I'm working in the workspace, not in the project
The cocoapods configuration file in the new configuration is properly set
Build locations in the preferences seem fine
For the record, the issue has been solved. So, as I said, I use cocoapods, but my current setup is that a single podfile, and workspace is used for 3 projects that share some common libraries. As explained in this issue, cocoapods will only consider one project out of all those that are specified in the podfile, and it turns the one project (out of three) that it was using, didn't have the beta configuration, so it didn't feel the need to prepare for it. So when it was time to build the project with the beta configuration, cocoapods would be built for the release configuration, and put in some folder specific to release, so the beta project wouldn't be able to find it.
Fixing was a matter of creating the beta configuration for all projects present in the workspace, forcing cocoapods to prepare accordingly. Then, Xcode would be able to wire up everything appropriately.

Resources