I have experienced a strange behaviour, when I run the tests from Xcode or I execute this command from terminal:
xcodebuild test -scheme '<MY_APP>'
the tests are succeed in both cases although in the second case tests are successful, however I need to specify a test device obviously. When I try to do that and execute the same command with the -destination flag:
xcodebuild test -scheme '<MY_APP>' -destination "platform=iOS Simulator,name=iPhone XS,OS=latest"
I get this error:
e2019-02-18 18:39:22.625 xcodebuild[36312:791798] 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, NSUnderlyingError=0x7f8a38637410 {Error Domain=IDETestOperationsObserverErrorDomain Code=5 "Test runner exited before starting test execution." UserInfo={NSLocalizedDescription=Test runner exited before starting test execution., NSLocalizedRecoverySuggestion=If you believe this error represents a bug, please attach the result bundle at /Users/<MY_USER>/Library/Developer/Xcode/DerivedData/<MY_APP>/Logs/Test/<MY_APP>-2019.02.18_18-37-12-+0100.xcresult}}} Generating coverage data... Generated coverage report: /Users/<MY_USER>/Library/Developer/Xcode/DerivedData/<MY_APP>-fbdolvrdfafpjbenwwqzgnlfkpoa/Logs/Test/Test-<MY_APP>.02.18_18-37-12-+0100.xcresult/1_Test/action.xccovreport Testing failed: <MY_APP>.app (36589) encountered an error (Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. (Underlying error: Test runner exited before starting test execution.)) ** TEST FAILED **
Other things to mention: This is a Cordova application. The native iOS part is written in Objective-C. But I am using some libraries which are written in Swift. I need xcodebuild for testing the application on my server. Any suggestion what could cause this issue? Also for the first time when I execute the command without the destination flag codesigning is successful, but when I did it with the destination flag it is empty:
CodeSign /Users/<MY_USER>/Library/Developer/Xcode/DerivedData/<MY_APP>-fbdolvrdfafpjbenwwqzgnlfkpoa/Build/Products/Debug-iphonesimulator/<MY_APP>.app/PlugIns/<MY_APP>Tests.xctest (in target: <MY_APP>Tests)
cd /Users/<MY_USER>/projects/my_project/
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
Signing Identity: "-"
UPDATE:
Somehow I could get the cause of the problem, which is this well known error:
dyld: Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib
Referenced from: /Users/<MY_USER>/Library/Developer/CoreSimulator/Devices/5AEAA313-0C65-49D8-BC20-DCC9994719C4/data/Containers/Bundle/Application/48DC52C0-4BC6-45ED-9AEE-A0E1F5C8BA1B/P2P-1-<MY_APP>.app/Frameworks/<REQUIRED_FRAMEWORK>.framework/<REQUIRED_FRAMEWORK>
You might think that from this point on the solution was is easy and straight forward, but it was not.
Because this library loading error pointed to a framework I was stucked...
I tried these: dyld: Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib
Xcode - Bundle format unrecognized, invalid, or unsuitable
References to Removed Framework in project.pbxproj File
The Always Embed Swift Standard Libraries
has set to YES
in the app, but I am not sure wether it has set to YES
in the given framework as well.
All in all the solution was from this question: dyld: Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib
where LuisCien suggesting to specifically use print()
anywhere in the code will somehow force libswiftSwiftOnoneSupport.dylib
to be loaded and the issue will go away.
Tests are now running although I am very curious why this ,,hack,, works.
Also tests are only fails when I try to run it with simulator with Xcode or with xcodebuild.