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?

Frant
  • 5,382
  • 1
  • 16
  • 22
Kazim Walji
  • 71
  • 1
  • 1
  • 2
  • You can try the top answer of this ask. [link here](https://stackoverflow.com/questions/65978359/xcode-error-building-for-ios-simulator-but-linking-in-dylib-built-for-ios-f) – Bomi Chen May 11 '21 at 07:48

4 Answers4

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
lchamp
  • 6,592
  • 2
  • 19
  • 27
  • 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. – ChrisH Feb 16 '21 at 14:59
  • 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'. – Ali Seymen Nov 20 '21 at 06:41
  • 4
    "arm64" is the architecture of M1 right? Why do we need to exclude it? Doesn't make sense.. – Hlung Mar 16 '22 at 09:17
  • ... 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! – groteworld Mar 31 '22 at 15:02
  • 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. – Shiv Kumar Apr 21 '22 at 10:57
  • Pod install is enough though – Victor Carmouze May 19 '22 at 13:24
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
serenn
  • 1,828
  • 1
  • 15
  • 11
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.

1

Open your Build Settings and set Excluded Architectures value as arm64

enter image description here

Vishnu Hari
  • 111
  • 1
  • 10