Reputation: 1395
When running unit tests on an M1 machine a number of bundle errors are being generated and are crashing the test suite immediately.
Specifically:
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)
The same unit tests run as expected on an Intel-based Mac.
Upvotes: 1
Views: 1697
Reputation: 1395
Turns out there was a subtle warning being generated that lead to the solution.
In the unit test target's build settings, under Packaging, if you turn on "Generate Info.plist File" or manually specify an Info.plist, this fixes the issue.
Upvotes: 4