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.