Can't build to simulator on Apple Silicon

Using Xcode 12.2, the specific error is "building for iOS Simulator, but linking in object file built for iOS, file '.../FIRAnalyticsConnector' for architecture arm64".

I've seen reports of this as an Xcode 12/Cocoapods issue that my project didn't have with 12.1 or 12.0. It only popped up when trying to build on my new M1 MacBook Air and Xcode 12. I've tried everything that's been reported to fix it, no dice.

1) I've tried "pod install" & "pod update" with a Rosetta2 version of Terminal. Both complete without error, but Xcode still can't build.
2) I've set excluded architectures to "Arm64" on the project, target and pod project.
3) I've added x8664 and i386 to Architectures for project, target and pod project.
4) I've set all configurations to "Build Active Architecture Only" to Yes.
5) I've even created (and deleted) a "VALID
ARCHS" user defined setting with the proper architectures to all three projects.
6) I've cleaned build folder many times and deleted derived data folder completely, and restarted Xcode.

Still I get that same error. I can build to device, which I guess is my only choice at the moment. Anything else I can try?

Accepted Reply

The issue is with the Firebase/Analytics pod. The Firebase team has been notified and are working on a fix. Follow the issue here: https://github.com/firebase/firebase-ios-sdk/issues/6520

For the time being, you can remove the pod to continue development until the fix is released.
  • Over a year later, the issue persists. Surely this should have been sorted by now. Almost every developer worth their salt will be using M1 based machines at this point.

Add a Comment

Replies

This has solved my problem: https://stackoverflow.com/a/63622570/1981420

Go to applications folder, right click on xcode, Get Info, select checkbox Open using Roseta

I found the fix (really easy) in a blog of Narlei dev (I can't paste the URL)

1- Set exclude arm64 architecture in your project

2- This at the end of your Podfile

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

I spent 3 days on this issue beating my head against the wall. Today, I finally cracked it and understood the problem. I am working on a highly modular project with ~100 frameworks. When migrating from the X86_64 (Intel) architecture to arm64 (M1) I was always getting this error:

Could not find module 'MyModule' for target 'x86_64-apple-ios-simulator'; found: arm64-apple-ios-simulator, at /my/path/

when building natively on M1.

The reason is that the simulator runs natively on M1 but the simulated app runs still under Intel. That's why the x86_64 architecture was built in the first place. The two architectures are now beating each other as the simulator is arm64 while the simulated app is X86_64. Removing the arm64 architecture for the pods and project settings fixed the issue and I can build the project entirely on M1 now.

Here are screenshots from the ActivityMonitor. AchieveMe is the app running in the simulator.

To fix the problem for Cocoapods you can simply do:

target.build_configurations.each do |config|
  config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
end

I am using XcodeGen and there it can simply be added under debug configuration as:

YourSettings
...
configs:
      Debug:
        EXCLUDED_ARCHS[sdk=iphonesimulator*]: arm64

Best of luck, I hope it helps.

I can sleep in peace now.

  • Hello.I don't understand this : "The reason is that the simulator runs natively on M1 but the simulated app runs still under Intel". You are telling here that Xcode produce a x86_64 binary that runs on a arm simulator ? Hoe does that work ?

Add a Comment