无法找出报告FBSnapshotTestCase image not found while running Xcode test
的原因。
我尝试在目标FBSnapshotTestCase
中关联ChartTests
,但仍然看到同样的错误。
我对此不熟悉,有人可以帮忙吗?提前谢谢。
重现:
从https://github.com/danielgindi/Charts
下载项目导航到项目根目录
(可选)运行carthage bootstrap
以安装依赖项。该项目有一个依赖性检查,所以如果你不运行它,它将在启动测试时运行它。
输入
xcodebuild -project' Charts.xcodeproj' -scheme' ChartsTests' -configuration' Debug' -sdk iphonesimulator -destination id =' E40B5365-EF82-430D-A767-2A37995CCEE1'清洁构建测试
目标ID可以是机器上模拟器的任何uuid。
然后它报告:
2017-04-20 13:47:57.611 xctest[90924:13099756] The bundle “ChartsTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2017-04-20 13:47:57.611 xctest[90924:13099756] (dlopen_preflight(/Users/user/Library/Developer/Xcode/DerivedData/Charts-ambsdrskvocwekcmoobyhanaiixm/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/ChartsTests.xctest/ChartsTests): Library not loaded: @rpath/FBSnapshotTestCase.framework/FBSnapshotTestCase
Referenced from: /Users/user/Library/Developer/Xcode/DerivedData/Charts-ambsdrskvocwekcmoobyhanaiixm/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/ChartsTests.xctest/ChartsTests
Reason: image not found)
2017-04-20 13:47:57.625 xcodebuild[90311:13086990] Error Domain=IDETestOperationsObserverErrorDomain Code=6 "Early unexpected exit, operation never finished bootstrapping - no restart will be attempted" UserInfo={NSLocalizedDescription=Early unexpected exit, operation never finished bootstrapping - no restart will be attempted}
Testing failed:
Test target ChartsTests encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted)
** TEST FAILED **
答案 0 :(得分:0)
事实证明我需要在Build阶段添加运行脚本,让carthage复制框架:
从https://github.com/Carthage/Carthage#if-youre-building-for-ios-tvos-or-watchos复制:
在应用程序目标的“构建阶段”设置选项卡上,单击“+”图标并选择“新建运行脚本阶段”。创建一个运行脚本,在其中指定shell(例如:/ bin / sh),将以下内容添加到shell下面的脚本区域:
/usr/local/bin/carthage copy-frameworks
并在“输入文件”下添加要使用的框架的路径,例如:
$(SRCROOT)/Carthage/Build/iOS/FBSnapshotTestCase.framework