What to do when you can’t run iOS simulator on Apple Silicon Mac (arm64 binary error)

Depending on the framework incorporated into the application, the following error may occur and prevent the iOS simulator from running on an Apple Silicon Mac.

ld: in /Volumes/Data/src/RK/TechGakuWebSite/SampleCodes/OpenCVTest_iOS/common/opencv2.framework/opencv2(ios_conversions.o), building for iOS Simulator, but linking in object file built for iOS, for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This example of error output occurs in OpenCV 4.6.0. This article will show you how to deal with it.

TOC

Error Cause

When an app was built with arm64 for the iOS simulator on an Apple Silicon Mac, it seems to be due to the fact that the framework for the iOS device was linked to the build for the iOS simulator when the framework incorporated was not fully compatible with Xcode 12 or later architecture or Apple Silicon.

How to deal with it

Apple Silicon Macs have Rosetta2, so binaries built with the x86_64 version can still be used in the iOS simulator and Xcode’s SwiftUI preview.

When building for the iOS simulator, configure it not to build with arm64. Do the following.

STEP
Open the “Build Settings” tab of the app’s target settings.
STEP
Select “Debug” under “Excluded Architectures” in “Architectures”.
STEP
Click the “+” button displayed in the “Debug” row. “Any SDK” will be added.
Click "+" button
Click “+” button
STEP
Change the added “Any SDK” to “Any iOS Simulator SDK”.
STEP
Enter “arm64” in the “Any iOS Simulator SDK” setting. This will prevent debug builds for the iOS Simulator from building with arm64.
STEP
Do as same as steps (4) and (5) to set arm64 for the “Release” build.
Configure for Release build
Configure for Release build
Let's share this post !

Author of this article

Akira Hayashiのアバター Akira Hayashi Representative, Software Engineer

I am an application developer loves programming. This blog is a tech blog, its articles are learning notes. In my work, I mainly focus on desktop and mobile application development, but I also write technical books and teach seminars. The websites of my work and books are here -> RK Kaihatsu.

TOC