我有一个现有的Objective-C项目,我想添加一个新的
Xcode 7 UI测试目标与
OHHTTPStubs作为依赖.
@H_403_2@我在Xcode中添加了新的(Swift 2.0)UI测试目标,然后将其添加到我的Podfile中:
target 'FooUITests' do pod 'OHHTTPStubs','4.0.1' end@H_403_2@我运行荚更新,清理和重建.但是当我尝试导入OHHTTPStubs在模板UI测试.swift文件Xcode为我创建的顶部,它抱怨“没有这样的模块’OHHTTPStubs’”. @H_403_2@我正在使用Cocoapods版本0.37.2 – 正在将一个Objective-C依赖关系导入Swift(… UI测试)目标甚至意味着工作? @H_403_2@更新:如我在下面的self-answer中所述,添加use_frameworks!到我的Podfile让我干净的编译 – 我可以导入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)@H_403_2@尽管我的〜/ Library / Developer / DerivedData目录下似乎已经有了Release-iphoneos和Release-iphonesimulator的OHHTTPStubs.framework. @H_403_2@关于发生什么的任何提示?
解决方法
原来所有我需要做的是告诉Cocoapods使用_frameworks! (仅适用于Swift目标)在Podfile中:
target 'FooUITests' do use_frameworks! pod 'OHHTTPStubs','4.0.1' end