【发布时间】:2021-12-18 21:14:51
【问题描述】:
在 M1 机器上运行单元测试时,会生成一些捆绑错误,并立即使测试套件崩溃。
具体来说:
- 未能加载测试包
- 找不到合适的图片
- 试图加载未签名的库
2021-11-04 08:53:33.378375-0600 xxx[81944:1274939] Failed to load test bundle from file:///Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit%20Tests.xctest/: Error Domain=NSCocoaErrorDomain Code=3587 "dlopen_preflight(/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests): no suitable image found. Did find:
/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests: code signature in (/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests) not valid for use in process using Library Validation: Trying to load an unsigned library" UserInfo={NSLocalizedFailureReason=The bundle is damaged or missing necessary resources., NSLocalizedRecoverySuggestion=Try reinstalling the bundle., NSFilePath=/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests, NSDebugDescription=dlopen_preflight(/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests): no suitable image found. Did find:
/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests: code signature in (/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests) not valid for use in process using Library Validation: Trying to load an unsigned library, NSBundlePath=/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest, NSLocalizedDescription=The bundle “Unit Tests.xctest” couldn’t be loaded because it is damaged or missing necessary resources.}
2021-11-04 08:53:33.683690-0600 xxx[81944:1274939] The bundle “Unit Tests.xctest” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2021-11-04 08:53:33.683757-0600 xxx[81944:1274939] (dlopen_preflight(/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests): no suitable image found. Did find:
/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests: code signature in (/Users/xxx/Library/Developer/XCTestDevices/FDCD6684-3D06-48C9-81E3-DE82C6AB2CCB/data/Containers/Bundle/Application/7143E7F2-E59A-4578-971A-A2A20D42DDB6/xxx.app/PlugIns/Unit Tests.xctest/Unit Tests) not valid for use in process using Library Validation: Trying to load an unsigned library)
相同的单元测试在基于 Intel 的 Mac 上按预期运行。
【问题讨论】:
标签: ios xcode unit-testing