Edward Dale
Edward Dale

Reputation: 30133

Project/workspace structure for multiple apps with CocoaPods

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?

Upvotes: 25

Views: 9532

Answers (1)

lehn0058
lehn0058

Reputation: 20237

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

Upvotes: 52

Related Questions