building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Hi,

I have found multiple questions on this topic but none of the proposals solves my problem so please stay with me on the description below since I am obviously missing something.

I have an iOS Framework that links with multiple static libraries from a C Open Source project using "Other Linker flags" and "Library search paths". These .a files are all fat binaries including arm64 and x86_64 versions.

This Framework is later used by a regular iOS app after being packed into an XCFramework (do note, when generating the XCFramework I use EXCLUDED_ARCHS="arm64" for the simulator build since a long time and I think this is also wrong).

Everything works fine on device but I have never gotten the Simulator to work on my M1 Mac and now I am trying to fix that but without success, when trying to start the simulator on M1 I get this error for the first fat .a found:

building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

I do not want to exclude arm64 arch for the simulator as suggested in some posts since I want to be able to run the app in arm64 mode on the Simulator. Also, when starting the simulator on my M1 (not using Rosetta) I am expecting it to run in arm64 mode so then it makes no sense that it complains that the static lib is an arm64 lib right?

I have tried changing Build only active archs and other suggestions but nothing has helped. I also checked the fat binary used from the framework with otools as suggested by @eskimo in another post and it spat out this: Load command 1 cmd LC_BUILD_VERSION cmdsize 24 platform 2 minos 13.0 sdk 15.4 ntools 0

which I think is correct, PLATFORM_IOS.

I assume the arm64 .a file that runs in the xCode Simulator is the same as the arm64 .a that runs on device right? Or do I have to build arm64 for the Mac platform to run the iOS simulator on M1?

Very grateful for any ideas on what might be wrong.

Answered by DTS Engineer in 721614022

I assume the arm64 .a file that runs in the xCode Simulator is the same as the arm64 .a that runs on device right? Or do I have to build arm64 for the Mac platform to run the iOS simulator on M1?

Neither is accurate. You need to rebuild the library to specifically target the iOS Simulator — this is not the same as the arm64 build for iOS devices, and targeting the Mac platform is also not the way forward for creating a build supporting simulators on Apple silicon natively.

Accepted Answer

I assume the arm64 .a file that runs in the xCode Simulator is the same as the arm64 .a that runs on device right? Or do I have to build arm64 for the Mac platform to run the iOS simulator on M1?

Neither is accurate. You need to rebuild the library to specifically target the iOS Simulator — this is not the same as the arm64 build for iOS devices, and targeting the Mac platform is also not the way forward for creating a build supporting simulators on Apple silicon natively.

Thank you @edford that changed everything. I did not understand that from the error description. Just compiling the C libs for arm64 simulator and my app started immediately in the Simulator.

building for iOS Simulator, but linking in object file built for iOS, for architecture arm64
 
 
Q