Can't figure out why report FBSnapshotTestCase image not found while running Xcode test
.
I tried to link FBSnapshotTestCase
in Target ChartTests
, but still seeing the same error.
I am not familiar with this, can anyone help? Thank in advance.
To reproduce:
Download the project from https://github.com/danielgindi/Charts
navigate to the project root,
(optional) run
carthage bootstrap
to install dependency. The project has a dependency check, so if you don't run this, it will run it when launching the test.enter
xcodebuild -project 'Charts.xcodeproj' -scheme 'ChartsTests' -configuration 'Debug' -sdk iphonesimulator -destination id='E40B5365-EF82-430D-A767-2A37995CCEE1' clean build test
the destination id could be any uuid of the simulator on the machine.
Then it reports:
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 **
It turned out I need to add run script in Build phases, and let carthage copy the frameworks:
copy from https://github.com/Carthage/Carthage#if-youre-building-for-ios-tvos-or-watchos:
On your application targets’ “Build Phases” settings tab, click the “+” icon and choose “New Run Script Phase”. Create a Run Script in which you specify your shell (ex: /bin/sh), add the following contents to the script area below the shell:
and add the paths to the frameworks you want to use under “Input Files”, e.g.: