xctool 构建失败:在“Debug-iphonesimulator”下找不到测试包

Posted

技术标签:

【中文标题】xctool 构建失败:在“Debug-iphonesimulator”下找不到测试包【英文标题】:xctool build failure: Test bundle not found under `Debug-iphonesimulator` 【发布时间】:2015-12-16 16:42:43 【问题描述】:

我在运行 xctool build 时遇到故障。我的命令如下:

xctool clean build run-tests -only 'MyApp KIF Tests' -workspace MyApp.xcworkspace/ -scheme 'Debug'  -destination "platform=ios Simulator,name=iPhone 6,OS=latest" -sdk iphonesimulator -reporter junit -reporter plain

构建失败并出现以下错误:

Failed to query the list of test cases in the test bundle: Test bundle not found at: /Users/myusername/Library/Developer/Xcode/DerivedData/MyApp-blbvnisblktossbxwcmnxafkngts/Build/Products/Debug-iphonesimulator/MyApp KIF Tests.xctest

我在错误消息中指定的路径中查找了MyApp KIF Tests.xctest,确实找不到该文件。但是,此文件确实存在于不同的路径下:

/Users/myusername/Library/Developer/Xcode/DerivedData/MyApp-blbvnisblktossbxwcmnxafkngts/Build/Products/Debug-iphoneos/MyApp KIF Tests.xctest

这两个路径的唯一区别是一个在Debug-iphonesimulator下,另一个在Debug-iphoneos下。

我还注意到,在 target -> Build Settings -> Build Locations -> Per-configuration Build Products Path -> Debug 下,值是$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME),其评估结果为build/OktaVerify.build/Debug-iphoneos。所以第一个问题是:为什么$(EFFECTIVE_PLATFORM_NAME) 评估为Debug-iphoneos?我需要更改什么配置以使其评估为 Debug-iphonesimulator 以便 xctool 可以找到它?

接下来,我将$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 的值硬编码为Debug-iphonesimulator,希望看到它正常工作。但是,我得到了同样的错误。我的第二个问题是,为什么即使构建产品路径指定Debug-iphonesimulator,xctest 文件也会出现在Debug-iphoneos 文件夹下?指定 Debug-iphoneos 的设置是什么?

环境为 Xcode 7.2 和 xctool 版本 0.2.8。

【问题讨论】:

这个测试目标是 UIAutomation 测试目标吗? @BandoKal 这是一个测试目标,但不是 UIAutomation。目前我们仍在使用 KIF 进行 UI 测试 @SeaJelly 你解决过这个问题吗? @jungledev 是的,最后我从上面的命令中删除了“-sdk iphonesimulator”,它开始工作了 您可以在下面的正式回答部分回答您自己的问题,接受您的回答,这将使您获得对您的回答的支持。感谢您的及时回复! 【参考方案1】:

我通过从 xctool 命令中删除“-sdk iphonesimulator”解决了这个问题。这样它会根据目标类型自动选择合适的 sdk。

【讨论】:

以上是关于xctool 构建失败:在“Debug-iphonesimulator”下找不到测试包的主要内容,如果未能解决你的问题,请参考以下文章

Swift 测试在本地通过,但在 Travis-CI 上构建失败

运行 xctool 运行测试而不在机器上构建测试

在构建脚本中使用 xctool 和 xcodebuild 进行代码签名后,ITC 上的代码签名权利无效

ERROR ITMS-90046 using xctool / xcodebuild vs XCode Archive 的成功

使用 xctool 在没有模拟器的情况下进行测试

ios shell打包脚本 xctool