I'm running Xcode 13.4.1 on an M1 and trying to run the test bundle.
What I did:
- Created a target whose configuration includes the standard architectures as well as x86_64.
- Excluded architecture arm64 for that target.
- Made sure 'Build Active Architecture Only' is set to No for this target.
The project builds successfully on M1 but the tests immediately fail with the error:
System: Failed to load the test bundle ... mach-o file but is an incompatible architecture (have ‘x86_64’, need ‘arm64’)
I checked the build log and indeed the linker command appears to target x86_64, it's at the start of the command:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target x86_64-apple-ios11.0-simulator ...
But I thought this is what I'm supposed to be doing as I'm running this on my M1 simulator. If I try to exclude arm64 my project doesn't build anymore (I understood this has to do with the way some pods in my dependencies are running, requiring arm64 to be excluded).
Is there a way to make the project build for M1 but the tests to also run?
I saw similar questions but nothing matched this case and solutions didn't work.