我在使用 Cocoapods 和 Xcode 7 beta 6 时遇到问题:我有一个包含三个不同测试目标(测试、UITests、IntegrationTests)的项目。我的 Pod 似乎在第一个目标(“测试”)上工作得很好,但其他目标有问题:
- 如果我不在后两个目标中引用任何 Cocoapods,一切都会正常构建。
- 但是,当我尝试使用其中一个 Pod(本例中为 XCGLogger)时,我收到链接器错误。
- 我检查了构建阶段,发现两个目标都缺少
Embed Pods Frameworks
,因此我手动添加了它。 - 执行此操作并清理、删除派生数据后,问题仍然存在。
随附的屏幕截图显示了链接器错误。同样,只有当我尝试在后两个目标中使用 XCGLogger 时,才会发生这种情况。它在第一个目标中运行良好。
为了彻底...这是我正在使用的 Podfile:
platform :ios, "8.0"
use_frameworks!
target 'Glimpulse' do
pod "SwiftSpinner", :git => 'https://github.com/zbeckman/SwiftSpinner.git'
pod 'XCGLogger', :git => 'https://github.com/DaveWoodCom/XCGLogger.git', :branch => 'swift_2.0'
pod 'GRValidation', '~> 0.2'
end
target 'GlimpulseTests' do
pod "SwiftSpinner", :git => 'https://github.com/zbeckman/SwiftSpinner.git'
pod 'XCGLogger', :git => 'https://github.com/DaveWoodCom/XCGLogger.git', :branch => 'swift_2.0'
pod "Nimble", :git => 'https://github.com/Quick/Nimble.git', :branch => 'swift-2.0'
pod "Quick", :git => 'https://github.com/zbeckman/Quick.git', :branch => 'swift-2.0'
pod 'GRValidation', '~> 0.2'
# pod "SwiftCheck", :git => 'https://github.com/zbeckman/SwiftCheck.git', :branch => 'swift-develop'
end
target 'GlimpulseUITests' do
pod "SwiftSpinner", :git => 'https://github.com/zbeckman/SwiftSpinner.git'
pod 'XCGLogger', :git => 'https://github.com/DaveWoodCom/XCGLogger.git', :branch => 'swift_2.0'
pod "Nimble", :git => 'https://github.com/Quick/Nimble.git', :branch => 'swift-2.0'
pod "Quick", :git => 'https://github.com/zbeckman/Quick.git', :branch => 'swift-2.0'
pod 'GRValidation', '~> 0.2'
# pod "SwiftCheck", :git => 'https://github.com/zbeckman/SwiftCheck.git', :branch => 'swift-develop'
end
target 'GlimpulseIntegrationTests' do
pod "SwiftSpinner", :git => 'https://github.com/zbeckman/SwiftSpinner.git'
pod 'XCGLogger', :git => 'https://github.com/DaveWoodCom/XCGLogger.git', :branch => 'swift_2.0'
pod "Nimble", :git => 'https://github.com/Quick/Nimble.git', :branch => 'swift-2.0'
pod "Quick", :git => 'https://github.com/zbeckman/Quick.git', :branch => 'swift-2.0'
pod 'GRValidation', '~> 0.2'
# pod "SwiftCheck", :git => 'https://github.com/zbeckman/SwiftCheck.git', :branch => 'swift-develop'
end
link_with 'GlimpulseUITests'
link_with 'GlimpulseIntegrationTests'
最佳答案
啊哈。好吧,我想我在经历了删除、重新创建、pod install
ing、重复……以及摆弄 Xcode 目标的痛苦和痛苦之后,我想通了。我的发现:
Cocoapods 0.38.2 不喜欢 Xcode 7 beta 6 的新“iOS UI 测试包”目标类型。
在设置新目标并运行 pod install
时,主要问题很明显。安装似乎运行良好,但如果您查看构建阶段,就会发现缺少嵌入 Pod 框架阶段。但是,如果我手动创建此阶段(根据目标调整路径),它就会构建。
但是...奇怪的事情仍然发生。上面显示的错误(关于当前架构的链接)仍然会发生。这是最奇怪的部分:如果我将目标更改为使用“仅针对事件架构构建:否” '然后一切就都正常了。我不明白最后一点,因为 Pod 应该只针对当前架构构建。然而...如果集成被破坏了那么...好吧,谁知道呢,也许它会在下一个 Cocoapods 版本中得到修复。
另一个令人失望的发现:新的 UI 测试目标类型似乎不支持 @testable
功能。真糟糕。希望他们将其添加到 Xcode 7 的最终版本中...
关于ios - Cocoapods 无法正确链接第三个、第四个目标(Xcode 7 beta 6),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32368665/