繁体   English   中英

升级到Xcode 5.1后,命令行中的运行单元测试失败

[英]Running unit tests from the command line fail after upgrading to Xcode 5.1

升级到Xcode 5.1后,从命令行运行的单元测试停止工作。

以下是运行xcodebuild test -workspace MyApp.xcworkspace -scheme MyApp -sdk iphonesimulator -configuration Debug时发生的情况xcodebuild test -workspace MyApp.xcworkspace -scheme MyApp -sdk iphonesimulator -configuration Debug

[...]
2014-03-11 15:32:08.392 Test Host[67583:907] Error loading /Users/0xced/Library/Developer/Xcode/DerivedData/MyApp-cdhjwjcbamuhpvfislepygilkusg/Build/Products/Debug-iphonesimulator/MyApp Tests.xctest/MyApp Tests:  dlopen(/Users/0xced/Library/Developer/Xcode/DerivedData/MyApp-cdhjwjcbamuhpvfislepygilkusg/Build/Products/Debug-iphonesimulator/MyApp Tests.xctest/MyApp Tests, 262): Library not loaded: /Developer/Library/Frameworks/XCTest.framework/XCTest
  Referenced from: /Users/0xced/Library/Developer/Xcode/DerivedData/MyApp-cdhjwjcbamuhpvfislepygilkusg/Build/Products/Debug-iphonesimulator/MyApp Tests.xctest/MyApp Tests
  Reason: image not found
IDEBundleInjection.c: Error loading bundle '/Users/0xced/Library/Developer/Xcode/DerivedData/MyApp-cdhjwjcbamuhpvfislepygilkusg/Build/Products/Debug-iphonesimulator/MyApp Tests.xctest'
** TEST SUCCEEDED **

虽然xcodebuild报告** TEST SUCCEEDED ** ,但测试显然没有运行。

我该如何解决这个错误?

该错误表示/Developer/Library/Frameworks/XCTest.framework/XCTest 因此,为了解决这个问题,我使用以下脚本向我的单元测试目标添加了一个运行脚本阶段:

install_name_tool -change "/Developer/Library/Frameworks/XCTest.framework/XCTest" "${SDKROOT}/Developer/Library/Frameworks/XCTest.framework/XCTest" "${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}"

它告诉单元测试包从当前SDK而不是从不存在的/Developer目录加载XCTest框架。

令人惊讶的是,此修复程序仅在我的计算机上需要,但在我们的CI服务器上不需要。 我的机器和CI服务器之间的差异分别包括:

  • 几个Xcode版本(4.6.3 + 5.0.2 + 5.1)仅限Xcode 5.1
  • 几个iOS模拟器(6.1 + 7.1)与iOS 7.1模拟器相比

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM