Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 872
Sazzad Hissain Khan Avatar asked Oct 01 '20 09:10

Sazzad Hissain Khan


People also ask

Is iOS simulator arm64?

Both ios-arm64-simulator and ios-x86_64-simulator represent two equivalent library definitions.

What architecture does iOS simulator use?

While the architecture of the iPhone is already arm64 , Intel used x86_64 simulators. With the new M1 series devices, the simulators also run on the arm64 architecture. Xcode already provides the default architecture build settings that help you build and ship on all the platforms.

Does CloudKit work in simulator?

CloudKit does not work with 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.

like image 53
Eugene Dudnyk Avatar answered Oct 22 '22 16:10

Eugene Dudnyk


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

like image 1
Deeksha gupta Avatar answered Oct 22 '22 16:10

Deeksha gupta