Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Project/workspace structure for multiple apps with CocoaPods

Tags:

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?

like image 860
Edward Dale Avatar asked Oct 07 '12 17:10

Edward Dale


People also ask

How do I add dependencies to CocoaPods?

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.

What are the pros of using CocoaPods?

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.


1 Answers

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

like image 198
lehn0058 Avatar answered Oct 03 '22 19:10

lehn0058