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

Recently, I have updated my Xcode to the latest version (Version 12.2 (12B45b), and my project running fine for real devices. But when I try to run on iOS Simulator I am getting the following error.

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

To solve this problem we have to exclude arm64 for simulator architecture both from your project and the pod target.

Solution using Exclude Architectures

Solution for Project Target

  • Open your project in Xcode 12 and click on the targets
  • Navigate to Build Settings of your project.
  • Add Any iOS Simulator SDK with value arm64 inside Excluded Architectures.
Image for post
Image for post
Excluded Architectures arm64

If you are using custom XCConfig files, you can simply add this line for excluding simulator architecture.

EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64

Solution for Pod Target

You can manually add the Excluded Architectures in your pod project's Build Settings, but it will be overwritten when you use pod install.

Xcode 12 ➞ Pod Target ➞ Build Settings ➞ Excluded Architectures ➞ arm64

At the end of your Podfile add the following snippet and runpod install command through the terminal. It will write the necessary Build Settings every time you run pod install.

Solution using Build Active Architecture Only

Set “Build Active Architecture Only” (ONLY_ACTIVE_ARCH) to Yes for both your project and the pod target.

Solution for Project Target

  • Open your project in Xcode 12 and click on the targets
  • Navigate to Build Settings of your project.
  • Set Build Active Architecture Only to Yes
Image for post
Image for post

Solution for Pod Target

At the end of your Podfile add the following snippet and runpod install command through terminal.

Solution for CocoaPods Developer

If you are creating a library/framework using CocoaPods then add this line in your .podspec file

s.pod_target_xcconfig = { 
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64'
}
s.user_target_xcconfig = {
'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'arm64'
}

Why was this happening?

  • The architectures of our project were determined by $ARCHS_STANDARD. With the release of Xcode 12, $ARCHS_STANDARD includes arm64 for simulator builds. This will eventually be a problem when we are running on Apple Silicon Macs, but for now, we’ll be okay.

Questions?

Please feel free to comment below, if you have any questions.

If you like this article, feel free to share it with your friends and leave me a comment. Also, click on the 👏 clap button below to show how much you like the article.

Thanks for reading! 👨🏼‍💻

You can find me on:

Twitter | LinkedIn | GitHub | Medium | HackerRank | LeetCode | Stack Overflow

iOS Team Lead — Professional Mobile App Developer ǁ Swift ǁ Objective-C ǁ Lifelong Learner ǁ Blogger https://milanpanchal.github.io/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store