通过Cocoapods包含Xcode 7 UI测试依赖性?

Rob*_*ins 12 ios cocoapods swift xcode7 xcode-ui-testing

我有一个现有的Objective-C项目,我想添加一个新的Xcode 7 UI测试目标,OHHTTPStubs作为依赖项.

我在Xcode中添加了新的(Swift 2.0)UI测试目标,然后将其添加到我的Podfile:

target 'FooUITests' do
    pod 'OHHTTPStubs', '4.0.1'
end
Run Code Online (Sandbox Code Playgroud)

我跑pod update,清理,重建.但是当我尝试import OHHTTPStubs在模板UI测试的顶部测试.swift文件Xcode为我创建时,它抱怨"没有这样的模块'OHHTTPStubs'".

我正在使用Cocoapods版本0.37.2-将Objective-C依赖项导入到Swift(... UI测试)目标中,甚至可以工作吗?

更新:正如我在下面的自我回答中所述,添加use_frameworks!到我的Podfile让我得到了清晰的编译 - 我可以import OHHTTPStubs在我的测试文件的顶部,引用类和方法,代码完成工作 - 但是当我真正去运行测试时我得到Xcode控制台中的以下输出:

2015-06-18 10:06:57.134 XCTRunner[51557:609693] The bundle “FooUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2015-06-18 10:06:57.135 XCTRunner[51557:609693] (dlopen_preflight(/Users/foo/Library/Developer/CoreSimulator/Devices/38181A1B-67B1-4D7F-B434-85361533F985/data/Containers/Bundle/Application/83C68748-55A3-4A02-8862-C18ADEF895B5/FooUITests-Runner.app/PlugIns/FooUITests.xctest/FooUITests): Library not loaded: @rpath/OHHTTPStubs.framework/OHHTTPStubs
  Referenced from: /Users/foo/Library/Developer/CoreSimulator/Devices/38181A1B-67B1-4D7F-B434-85361533F985/data/Containers/Bundle/Application/83C68748-55A3-4A02-8862-C18ADEF895B5/FooUITests-Runner.app/PlugIns/FooUITests.xctest/FooUITests
  Reason: image not found)
Run Code Online (Sandbox Code Playgroud)

虽然我的目录下似乎有Release-iphoneosRelease-iphonesimulator构建.OHHTTPStubs.framework~/Library/Developer/DerivedData

有关正在发生的事情的任何提示?

Rob*_*ins 2

结果我需要做的就是告诉 Cocoapods use_frameworks!(仅适用于 Swift 目标)Podfile

target 'FooUITests' do
  use_frameworks!
  pod 'OHHTTPStubs', '4.0.1'
end
Run Code Online (Sandbox Code Playgroud)

  • 嗯,也许没那么快。尽管(因为?)进行了多次清理和重建,但它不再工作了。现在我收到“无法加载捆绑包“Foo”,因为它已损坏或缺少必要的资源。请尝试重新安装该捆绑包。” 每当我尝试实际运行测试时,尽管它确实构建了。 (2认同)