31

After updating to Xcode 12 the project gives me this error when building on simulator:

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

The framework is installed with cocoapods. It works with Xcode 11. Building on "Any iOS Device" or real iPhone with Xcode 12 also works just fine. What's different in Xcode 12?

Stefo
  • 636
  • 1
  • 8
  • 13

9 Answers9

24

I fixed this by ensuring the build setting VALID_ARCHS (now appearing at the bottom of Build Settings in Xcode 12) contains "x86_64".

That is:

  • Before I had: VALID_ARCHS = arm64, arm64e
  • After fixing: VALID_ARCHS = arm64, arm64e, x86_64

(A little counterintuitive, as the error message says it couldn't find the module for arm64-apple-ios-simulator, :shrug:)

Mete
  • 5,495
  • 4
  • 32
  • 40
  • Wow this actually fixed the issue! It finally runs successfully on simulator. Thanks! – Stefo Oct 19 '20 at 14:25
  • This one works, I tried replacing the value of `VALID_ARCHS` by what is given here: `arm64, arm64e, x86_64` – Yash Bedi Jan 14 '21 at 08:03
  • 4
    `VALID_ARCHS` is no longer here in Xcode 12.3. – aheze Jan 28 '21 at 04:18
  • 2
    @aheze yes it's been "missing" since before 12.3 actually. But you can just add it yourself to the `User-Defined` section at the bottom of Build Settings. – Mete Feb 01 '21 at 10:20
  • 1
    It's indeed misleading because of the `arm64` part, but the iOS Simulator actually runs natively on x86-64 (on Intel Macs), so the solution makes perfect sense. This is why it's a _simulator_, not an _emulator_. It's also why it's *incredibly* faster than Android emulators. Apple Silicon Macs also run it natively, but now on arm64, the same arch as iPhones and other Apple products. Maybe the error came to be this way because the simulator was renamed for the Apple Silicon transition. I don't have any insider information, just speculating. – Velociround Mar 29 '21 at 15:43
  • 4
    Xcode 12.5.1 - I don't see VALID_ARCHS in Build Settings – Kiran Jasvanee Jul 29 '21 at 14:51
  • To add it yourself as a user defined setting, click on the + icon at the top (to the right of Levels) – trees_are_great Oct 05 '21 at 14:34
  • 1
    This solution should be added to the client app target. If you are unable to find the VALID_ARCHS on Build settings, just add the User-Defined build setting by 'Editor -> Add Build Settings -> Add User-Defined Setting' – Balaji Malliswamy Nov 01 '21 at 12:11
  • this is the solution I was looking for. worked like a charm. thanks very much @Mete – Paras Gorasiya Nov 26 '21 at 04:48
  • Thanks for pointing this out, helpful! – Tommy Leong Mar 28 '22 at 13:31
  • thanks you saved my time. – Erhan Demirci Jun 16 '23 at 18:42
4

This situation presumably arises when you modify your project to suit the new M1 Macs, and then try to run the same project on an Intel Mac.

It basically tries to run on the ARM architecture and finds X86_64 instead.

To resolve the problem you just need to restrict the build operation to the active (X86_64) architecture only.

You can do this by setting Build Active Architectures only to YES.

enter image description here

Rufat Mirza
  • 1,425
  • 14
  • 20
3

I solved this by excluding arm64 in both app Target and test Target for Debug like the below pictures.

Tested and worked on Xcode 13.

enter image description here

enter image description here

Sajjad Hajavi
  • 501
  • 7
  • 9
3

Got this error on our app for library and this solved my problem:

close XCode

open Finder app and show there "Applications"

right click on icon Xcode and click on "Get info" (or something similar)

there is checkbox "Open with Rosseta" (or something similar). Select it

run Xcode again and try to build

https://developer.apple.com/forums/thread/123614?login=true

  • 1
    this works ESPECIALLY well if you installed the Ruby extension called "ffi" (sudo arch -x86_64 gem install ffi) onto your machine, but it will not work unless you include the Rosetta mentioned above. To activate ffi you will also need to run "arch -x86_64 pod install" into your project folder. This should help you with iOS simulator problems on your M1 machines if running a pre-M1 project. – John Pitts Dec 09 '21 at 23:32
  • Perfect, thanks. Similar to the comment above, I had a local Swift Package developed pre-M1 and it would only work for physical devices, not simulators. – App Dev Guy May 20 '22 at 13:41
1

You can try to set $(ARCHS_STANDARD) for VALID_ARCHS for Debug for Any iOS Simulator SDK and set YES for ONLY_ACTIVE_ARCH for Debug. It worked for me.

enter image description here

Nikaaner
  • 1,022
  • 16
  • 19
1

For M1 Chip Based Mac Follow the instructions below..

Applications > Xcode > Get Info> checked "Open using Rosetta"

Thats's it and you are good to go.

Tested in Xcode 13.3.1, Apple M1 Pro

emraz
  • 1,563
  • 20
  • 28
0

Current Working Solution

  post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
            config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
        end
    end
  end
Dhruv Parmar
  • 35
  • 1
  • 6
-2

In the newest version of Xcode, (Xcode 13.2) the option for VALID_ARCHS is no longer available. So i made the decision to switch the test device from a simulator to a physical device, in Xcode. I did not have the issue when running on a physical test device

kc ochibili
  • 3,103
  • 2
  • 25
  • 25
-4

You can try delete derived data of your app and then clean and build app, you can follow the steps of the following link https://programmingwithswift.com/delete-derived-data-xcode/