当我从 Xcode 运行测试或从终端执行此命令时,我遇到了一种奇怪的行为:
xcodebuild test -scheme '<MY_APP>'
尽管在第二种情况下测试成功,但两种情况下的测试都成功了,但是我显然需要指定一个测试设备。当我尝试这样做并使用 -destination 标志执行相同的命令时:
xcodebuild test -scheme '<MY_APP>' -destination "platform=iOS Simulator,name=iPhone XS,OS=latest"
我收到此错误:
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 **
其他要提及的事情:这是一个 Cordova 应用程序。原生 iOS 部分是用 Objective-C 编写的。但是我正在使用一些用 Swift 编写的库。我需要 xcodebuild 来测试我服务器上的应用程序。任何可能导致此问题的建议?同样,当我第一次在没有目标标志的情况下执行命令时,代码是成功的,但是当我使用目标标志执行该命令时,它是空的:
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: "-"
更新:
不知何故,我可以找到问题的原因,这是众所周知的错误:
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>
您可能认为从这一点开始,解决方案是简单而直接的,但事实并非如此。
因为这个库加载错误指向了一个我被卡住的框架......
我试过这些:dyld:库未加载:@rpath/libswiftSwiftOnoneSupport.dylib
在Always Embed Swift Standard Libraries
已设定YES
的程序,但我不知道羯羊它设置为YES
在给定的框架,以及。
总而言之,解决方案来自这个问题:dyld:未加载库:@rpath/libswiftSwiftOnoneSupport.dylib
LuisCien 建议print()
在代码中的任何地方专门使用会以某种方式强制libswiftSwiftOnoneSupport.dylib
加载,问题就会消失。
测试现在正在运行,尽管我很好奇为什么这个 ,,hack,, 有效。
此外,当我尝试使用带有 Xcode 或 xcodebuild 的模拟器运行它时,测试只会失败。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句