0

不知道为什么要举报FBSnapshotTestCase image not found while running Xcode test

我尝试FBSnapshotTestCase在 Target中链接ChartTests,但仍然看到相同的错误。

我不熟悉这个,有人可以帮忙吗?预先感谢。

重现:

从https://github.com/danielgindi/Charts下载项目

导航到项目根目录,

  1. (可选)运行carthage bootstrap以安装依赖项。该项目有一个依赖检查,所以如果你不运行它,它会在启动测试时运行它。

  2. 进入

    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 **
4

1 回答 1

0

原来我需要在构建阶段添加运行脚本,并让 carthage 复制框架:

从https://github.com/Carthage/Carthage#if-youre-building-for-ios-tvos-or-watchos复制:

在应用程序目标的“Build Phases”设置选项卡上,单击“+”图标并选择“New Run Script Phase”。创建一个运行脚本,在其中指定您的 shell(例如:/bin/sh),将以下内容添加到 shell 下方的脚本区域:

/usr/local/bin/carthage copy-frameworks

并在“输入文件”下添加要使用的框架的路径,例如:

$(SRCROOT)/Carthage/Build/iOS/FBSnapshotTestCase.framework
于 2017-04-21T06:47:06.170 回答