Project/workspace structure for multiple apps with CocoaPods

核能气质少年 提交于 2019-11-28 15:50:44

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/12771191/project-workspace-structure-for-multiple-apps-with-cocoapods

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!