xcode 带有 CocoaPods 的多个应用程序的项目/工作区结构
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12771191/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Project/workspace structure for multiple apps with CocoaPods
提问by Edward Dale
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.
我即将迁移我的应用程序以使用CocoaPods。我当前的目录结构如下图所示。我有一个包含 3 个项目 ( ipad
, ipod
, common
) 的工作区。ipad
和ipod
项目中有构建目标,依赖于common
项目。
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?
我的问题是,我应该如何将其迁移到 CocoaPods?看起来 CocoaPods 为Podfile
您创建的每个创建了一个新的工作区。我想保留我的 3 项目工作区结构,因为它似乎可以很好地将所有内容保持在一起。我应该Podfile
为每个带有目标的项目创建一个并Specfile
为公共项目创建一个吗?那么我如何在 XCode 中设置它呢?
回答by lehn0058
In the latest version at the time of this post, you need to have your podfile in the following format:
在本文发布时的最新版本中,您的 podfile 需要采用以下格式:
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: //github.com/CocoaPods/CocoaPods/issues/738