Apple M1 – Xcode error when build in simulator

If you have seen this error: “Building for iOS Simulator, but linking in dylib built for iOS, file for architecture arm64.”, this post is for you.

If you are a old iOS developer, you’ve seen the arm64 term.

Now with M1 we have problems again. But don’t worry, it’s simple.

ATTENTION! Follow the two steps! Will not work if you only change cocoapods. To solve this problem we have to exclude arm64 for simulator architecture both from your project and the pod target.

Step One: exclude arm64 architecture from your project.

Pay attention to the filter ALL, if you are looking Basic view, you cannot find the ‘Exclude Architetures’ option.

Both Debug and Release, change to Any iOS Simulator SDK – arm64.

Step Two: exclude arm64 architecture from cocoapods.

Do you know, if you change some settings in .xcworkspace, will be replaced by pod install.

Then we will script the changes in your Podfile:

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
  end
end

Now, run:

pod install

Done, now your project is running perfectly!

Recommended:

Apple M1 – Install fastlane

Apple M1 – Install cocoapods