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 Architechtures
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 valuearm64
inside Excluded Architectures.
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 run pod install
command through the terminal. It will write the necessary Build Settings every time you run pod install.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
end
end
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 run pod install
command through the terminal.
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"
end
end
end
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
includesarm64
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 | Tooter | LinkedIn | GitHub | Medium | HackerRank | LeetCode | Stack Overflow