如果使用模拟器,从 Xcode 和 xcodebuild 运行 xctests 会失败 - dyld:库未加载:@rpath/libswiftSwiftOnoneSupport.dylib 问题 - print()
Runing xctests from Xcode and xcodebuild fails if simulator used - dyld: Library not loaded: @rpath/libswiftSwiftOnoneSupport.dylib issue - print()
我遇到了一个奇怪的行为,当我 运行 来自 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>
您可能认为从现在开始,解决方案是简单直接的,但事实并非如此。
因为这个库加载错误指向一个框架,我被卡住了...
我试过这些:
Always Embed Swift Standard Libraries
已在应用程序中设置为 YES
,但我不确定它是否在给定框架中也已设置为 YES
。
总而言之,解决方案来自这个问题:
LuisCien 建议在代码中的任何地方专门使用 print()
会以某种方式强制加载 libswiftSwiftOnoneSupport.dylib
,问题就会消失。
测试现在 运行ning 尽管我很好奇为什么这个 ,hack, 有效。
此外,只有当我尝试使用带有 Xcode 或 xcodebuild 的模拟器 运行 时,测试才会失败。
我遇到了一个奇怪的行为,当我 运行 来自 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>
您可能认为从现在开始,解决方案是简单直接的,但事实并非如此。
因为这个库加载错误指向一个框架,我被卡住了...
我试过这些:
Always Embed Swift Standard Libraries
已在应用程序中设置为 YES
,但我不确定它是否在给定框架中也已设置为 YES
。
总而言之,解决方案来自这个问题:
LuisCien 建议在代码中的任何地方专门使用 print()
会以某种方式强制加载 libswiftSwiftOnoneSupport.dylib
,问题就会消失。
测试现在 运行ning 尽管我很好奇为什么这个 ,hack, 有效。
此外,只有当我尝试使用带有 Xcode 或 xcodebuild 的模拟器 运行 时,测试才会失败。