I'm about to migrate my app to use CocoaPods. My current directory structure looks like the diagram below. I have one workspace that contains 3 projects (ipad
, ipod
, common
). There are build targets in the ipad
and ipod
projects with dependencies on the common
project.
MyGreatApp | +-- MyGreatApp.xcworkspace | +-- ipad | | | +-- ipad.xcodeproj | +-- (source code) | +-- ipod | | | +-- ipod.xcodeproj | +-- (source code) | +-- common | +-- common.xcodeproj +-- (source code)
My question is, how should I migrate this to CocoaPods? It looks like CocoaPods create a new workspace for each Podfile
that you create. I'd like to keep my 3-project workspace structure because it seems like it keeps everything together nicely. Should I create a Podfile
for each project with targets and a Specfile
for the common project? How do I set this up in XCode then?
After you have initially installed CocoaPods into your project, you can add new dependencies (or remove unused ones) by editing the Podfile. Then simply run pod install again.
CocoaPods is a tool that makes managing your project much simpler. It can save you a lot of effort and time when dealing with dependencies in your project as it makes adding, removing and updating libraries that much easier. For more on using and troubleshooting CocoaPods, check out the CocoaPods guides.
In the latest version at the time of this post, you need to have your podfile in the following format:
workspace 'Test' xcodeproj 'iphone/iphone.xcodeproj' xcodeproj 'iphone2/iphone2.xcodeproj' target :iphone do platform :ios, '6.0' pod 'RestKit' xcodeproj 'iphone/iphone.xcodeproj' end target :iphone2 do platform :ios, '6.0' pod 'RestKit' xcodeproj 'iphone2/iphone2.xcodeproj' end
I verified that this is working for multiple projects in an existing workspace.
See this post for more details: https://github.com/CocoaPods/CocoaPods/issues/738
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With