'Cocoapods won't work on new m1 mac Big Sur Xcode

I am getting rid of my 8 year old mac, and am switching to the new m1 macbook air, but none of my old projects are running. I have installed cocoapods succesfully, but a lot of my big projects are running into errors, even after updating all the pods and running everything through Rosetta. Here are some of the errors I am running into in Xcode:

Could not find module 'PodName' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator

No such module 'PodName'

These are just a few, encountering many errors. I tried updating these pods, reinstalling them, etc. but nothing is working. Has anyone with a m1 mac had any success with this?



Solution 1:[1]

You can tweak your project architecture or add the following at the very end of your Podfile (and run pod update again) :

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

Solution 2:[2]

This seems likely related to this question & answer here: Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Basically what you'll need to do is make sure that:

  • The architectures being built is set to Standard Architectures (ARCHS_STANDARD)
  • That you add an 'excluded' architecture setting, for Any iOS Simulator and set it to arm64

That should get you up and running.

One thing to note (that caught me up for a while): Make sure that you do not have the Build Setting of "Valid Architectures" (VALID_ARCHS). If you do, delete the line entirely. It was causing issues for me, because it was effectively ignoring the new paradigm that Apple wants us to use (Architectures + Excluded Architectures).

Finally, if you do not see VALID_ARCHS but you're still unable to run it, one thing that worked for me (since I also was coming back to an old project) was to:

  • Add in VALID_ARCHS and set it to Standard architectures
  • Build the app (get the errors as expected)
  • Delete the line
  • Re-build the app

Solution 3:[3]

This stumped me for ages.

You need to add the following line inside your pod file inside your project.

config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"

Add it for each build configuration. The full code to do this is:

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

There is also a chance that on an M1 machine you need to compile your pods using the x86_64 architecture. To do so running the following:

arch -x86_64 pod install

You can see the full solution on building for multiple architectures here.

Solution 4:[4]

Open your Build Settings and set Excluded Architectures value as arm64

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lchamp
Solution 2 serenn
Solution 3 James Skilton
Solution 4 Vishnu Hari