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

Milan Panchal
3 min readDec 14, 2020

--

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.
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

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

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Milan Panchal
Milan Panchal

Written by Milan Panchal

iOS Team Lead ǁ Swift ǁ Objective-C ǁ Lifelong Learner ǁ Blogger — Join Medium from the following link: https://medium.com/@milanpanchal24/membership

Responses (14)

What are your thoughts?