如何在使用 CocoaPods 时将自定义项目配置添加到 Xcode?
How to add custom project configurations to Xcode when using CocoaPods?
我有一个 iOS/OS X Xcode 项目,我在其中使用 CocoaPods,我似乎不知道如何添加我自己的项目配置(除了 Debug 和 Release) 而没有完全炸毁构建。
在项目中,我有一些目标,针对两个平台上的应用程序及其应用程序扩展。 Xcode 工作区当然还有 Pods 项目。
因为该项目为 iOS 和 Mac 构建目标,我使用 CocoaPods "targets" 将它们的 pods 组合在一起。我的 Podfile 看起来像这样:
source 'https://github.com/CocoaPods/Specs.git'
target :iOS do
platform :ios, '7.1'
link_with 'iOS', 'NozbeToday', 'NozbeShare', 'NozbeWatch'
# pods...
end
target :Mac do
platform :osx, '10.9'
link_with 'Mac'
# pods...
end
这就是我遇到问题的地方。到目前为止,我的项目中只有默认的 "Debug" 和 "Release" 配置。我想更改它们并为不同的配置添加一些新的 profile/bundle ID 组合。
…我卡住了。我不知道该怎么做。
问题的第一个迹象是每个 target/configuration 组合都发出警告 pod install
:
[!] CocoaPods did not set the base configuration of your project
because your project already has a custom config set. In order for
CocoaPods integration to work at all, please either set the base
configurations of the target NozbeToday
to Pods/Target Support
Files/Pods-iOS/Pods-iOS.dev debug.xcconfig
or include the
Pods/Target Support Files/Pods-iOS/Pods-iOS.dev debug.xcconfig
in
your build configuration.
我不明白这是什么意思以及如何解决这个问题。无论哪种方式,项目都不会构建——在最好的情况下,我会收到一个链接器错误,指出它找不到 Pods-something.a
…
好的,所以 half-way 通过写这个问题我自己弄明白了(是的橡皮鸭)。这是下一代的解决方案:
本质上,您必须在应用程序方案中添加对 Pods 目标的显式依赖。
您的方法是:编辑您的应用程序方案,转到“构建”部分,然后将 Pods 目标添加到 您的应用程序目标之上 。你应该看到这样的东西:
它会正常工作。
至于 pod install
上的 CocoaPods 警告,您需要使用 CP 为每个 Xcode 配置生成的 xcconfig
文件。你这样做的方式是:
- 在
Pods/Target Support Files
中找到 .xcconfig 文件
- 将它们拖放到 Xcode 项目中的 "Pods" 组(仅添加参考。不要复制到目标或添加到构建)
- 单击项目导航器中的项目,然后 select 项目本身(不是目标之一)。转到“信息”,然后在“配置”下为 "Based on Configuration file" 列中的每个配置和目标设置正确的 .xcconfigs。
您还需要在您的 Podfile 中添加类似这样的内容,让 CocoaPods 知道您的 Xcode 配置中哪些是 "debug"(未优化),哪些是 "release":
project '1Nozbe', {
'iOS 1 Dev Debug' => :debug,
'iOS 2 Dev AdHoc' => :release,
'iOS 3 Release Debug' => :debug,
'iOS 4 Release AdHoc' => :release,
'iOS 5 Release AppStore' => :release,
}
与 Cocoa 不完全相关Pods,但如果你碰巧有一些除 CP 之外的其他(sub-project)依赖项,你还需要做两件事:
- 添加对 sub-project 目标的显式依赖(如上面的屏幕截图所示)
- rename/add 配置在您的 sub-project 中,以便它们与您的主项目相同。 (否则,Xcode 只是不知道您的 sub-project 使用哪种配置)
在您的配置文件中添加这一行,就像导入头文件一样:
#include "Pods/Target Support Files/Pods/Pods.debug.xcconfig"
注意:是 #include
,不是 #import
无需向任何架构添加显式依赖项也无需拖放内容的另一种解决方案:
如何在使用 CocoaPods 时将自定义项目配置添加到 Xcode
通常,当您将自定义配置添加到 xcode 项目(调试和发布除外)时,您 应该 做的事情是 运行 pod install
.这将 fix/remake cocoapods 通常所做的更改。
如何乘坐CocoaPods did not set the base configuration of your project because...
警告
在Info
选项卡下的Configurations
设置中,在项目级别,您需要设置要使用的基础配置(在运行ning pod install时生成)
并且不要忘记告诉 cocoapods 它应该使用什么配置,换句话说 map your condfigurations with pods configurations,否则你的编译时间可能会急剧增加
为我修复的是:
- 将包含添加到自定义配置文件中,
- 在 Pod 文件中添加项目配置依赖项(使用您在信息 -> 配置和
下看到的名称
- 然后re-running pod 安装。
这是配置文件的包含 (SupportingFiles->Config->ConfigFiles)
#include "Pods/Target Support Files/Pods-ProjectName/Pods-ProjectName.release prod.xcconfig"
对我有帮助的链接:
Great Tutorial on setting up configs with Cocoapods
Project documentation Cocoapods
已更新
我有一个 iOS/OS X Xcode 项目,我在其中使用 CocoaPods,我似乎不知道如何添加我自己的项目配置(除了 Debug 和 Release) 而没有完全炸毁构建。
在项目中,我有一些目标,针对两个平台上的应用程序及其应用程序扩展。 Xcode 工作区当然还有 Pods 项目。
因为该项目为 iOS 和 Mac 构建目标,我使用 CocoaPods "targets" 将它们的 pods 组合在一起。我的 Podfile 看起来像这样:
source 'https://github.com/CocoaPods/Specs.git'
target :iOS do
platform :ios, '7.1'
link_with 'iOS', 'NozbeToday', 'NozbeShare', 'NozbeWatch'
# pods...
end
target :Mac do
platform :osx, '10.9'
link_with 'Mac'
# pods...
end
这就是我遇到问题的地方。到目前为止,我的项目中只有默认的 "Debug" 和 "Release" 配置。我想更改它们并为不同的配置添加一些新的 profile/bundle ID 组合。
…我卡住了。我不知道该怎么做。
问题的第一个迹象是每个 target/configuration 组合都发出警告 pod install
:
[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set. In order for CocoaPods integration to work at all, please either set the base configurations of the target
NozbeToday
toPods/Target Support Files/Pods-iOS/Pods-iOS.dev debug.xcconfig
or include thePods/Target Support Files/Pods-iOS/Pods-iOS.dev debug.xcconfig
in your build configuration.
我不明白这是什么意思以及如何解决这个问题。无论哪种方式,项目都不会构建——在最好的情况下,我会收到一个链接器错误,指出它找不到 Pods-something.a
…
好的,所以 half-way 通过写这个问题我自己弄明白了(是的橡皮鸭)。这是下一代的解决方案:
本质上,您必须在应用程序方案中添加对 Pods 目标的显式依赖。
您的方法是:编辑您的应用程序方案,转到“构建”部分,然后将 Pods 目标添加到 您的应用程序目标之上 。你应该看到这样的东西:
它会正常工作。
至于 pod install
上的 CocoaPods 警告,您需要使用 CP 为每个 Xcode 配置生成的 xcconfig
文件。你这样做的方式是:
- 在
Pods/Target Support Files
中找到 .xcconfig 文件
- 将它们拖放到 Xcode 项目中的 "Pods" 组(仅添加参考。不要复制到目标或添加到构建)
- 单击项目导航器中的项目,然后 select 项目本身(不是目标之一)。转到“信息”,然后在“配置”下为 "Based on Configuration file" 列中的每个配置和目标设置正确的 .xcconfigs。
您还需要在您的 Podfile 中添加类似这样的内容,让 CocoaPods 知道您的 Xcode 配置中哪些是 "debug"(未优化),哪些是 "release":
project '1Nozbe', {
'iOS 1 Dev Debug' => :debug,
'iOS 2 Dev AdHoc' => :release,
'iOS 3 Release Debug' => :debug,
'iOS 4 Release AdHoc' => :release,
'iOS 5 Release AppStore' => :release,
}
与 Cocoa 不完全相关Pods,但如果你碰巧有一些除 CP 之外的其他(sub-project)依赖项,你还需要做两件事:
- 添加对 sub-project 目标的显式依赖(如上面的屏幕截图所示)
- rename/add 配置在您的 sub-project 中,以便它们与您的主项目相同。 (否则,Xcode 只是不知道您的 sub-project 使用哪种配置)
在您的配置文件中添加这一行,就像导入头文件一样:
#include "Pods/Target Support Files/Pods/Pods.debug.xcconfig"
注意:是 #include
,不是 #import
无需向任何架构添加显式依赖项也无需拖放内容的另一种解决方案:
如何在使用 CocoaPods 时将自定义项目配置添加到 Xcode
通常,当您将自定义配置添加到 xcode 项目(调试和发布除外)时,您 应该 做的事情是 运行 pod install
.这将 fix/remake cocoapods 通常所做的更改。
如何乘坐CocoaPods did not set the base configuration of your project because...
警告
在Info
选项卡下的Configurations
设置中,在项目级别,您需要设置要使用的基础配置(在运行ning pod install时生成)
并且不要忘记告诉 cocoapods 它应该使用什么配置,换句话说 map your condfigurations with pods configurations,否则你的编译时间可能会急剧增加
为我修复的是:
- 将包含添加到自定义配置文件中,
- 在 Pod 文件中添加项目配置依赖项(使用您在信息 -> 配置和 下看到的名称
- 然后re-running pod 安装。
这是配置文件的包含 (SupportingFiles->Config->ConfigFiles)
#include "Pods/Target Support Files/Pods-ProjectName/Pods-ProjectName.release prod.xcconfig"
对我有帮助的链接:
Great Tutorial on setting up configs with Cocoapods
Project documentation Cocoapods
已更新