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

4

7

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?

Lagos answered 21/12, 2020 at 23:15 Comment(1)
You can try the top answer of this ask. link hereStraitlaced
M
10

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
Martyrdom answered 22/12, 2020 at 21:56 Comment(6)
This was the final step that brought it home for me. Maybe every other thing helped, maybe none of it did (I'm sure it all did), but without this final step, nothing would build for the simulator. Things would build ok for the device. Thanks for this. This actually works better than using Swift Package Manager, which is actually pretty disappointing, but here we are. Again, thanks @Ichamp.Roesler
If you still get an error despite this solution, you need to check project's iOS Deployment Target. It should me minimum iOS12. In my project it was iOS11, update it to iOS12 on your targets and don't forget to change it on podfile as platform :ios, '12.0'.Woodham
"arm64" is the architecture of M1 right? Why do we need to exclude it? Doesn't make sense..Saturate
... and then hidden 3 answers down on a random SO post. the answer i've been looking for for a few days. Thank you @lchamp!Corpulent
Using M1 Chip system, if we add this code into the pod file then it add the "arm64" into all pods project not into main Pod Target. How we can add into Main Pod Target.Checkbook
Pod install is enough thoughJudo
A
6

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
Aurelioaurelius answered 22/12, 2020 at 12:24 Comment(1)
Thank you for this. Simply adding arm64 to excluded arch worked for me!Kindred
R
2

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.

Ruderal answered 14/12, 2021 at 14:24 Comment(1)
"arch -x86_64 pod install" worked for me, that was a life saver thank you!Inclinatory
Y
1

Open your Build Settings and set Excluded Architectures value as arm64

enter image description here

Yeah answered 9/5, 2022 at 14:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.