Xcode12 - building for iOS Simulator, but linking in object file built for macOS, file 'dir/SomeFile.a' for architecture x86_64

Viewed 8102

Getting linker error in Xcode 12 when I am trying to build my large iOS app (hybrid, swift+objc). The application is building fine for real device, but It gives linker error when I am trying to run in Simulator directly with Debug configuration.

I have tried all possible solutions in other post here, but unfortunately it didn't work. Although the error in other post is different. I have checked Build for active architectures only to YES for Debug configs and NO for Release configs.

Other post error,

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

My error,

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

How can I resolve this issue? I need to run in both iOS real device and Simulator.

2 Answers

Wherever you got your library you should request the library that is compiled for iOS Simulator, not for macOS, although they have the same binary architectures that are returned via lipo -info <file>.

You can verify that your static (.a) or dynamic library (.dylib) is compiled for iOS Simulator using this command:

otool -l <path-to-library> | grep platform

The output means the following:

  • platform 7 - iOS Simulator
  • platform 6 - Mac Catalyst
  • platform 4 - watchOS
  • platform 2 - iOS
  • platform 1 - macOS

Here is the full definition of the enum for platform.

Try to add x86_64 in VALID_ARCHS in the User-defined section in Build Settings. enter image description here

Related