skip to Main Content

There is an odd error when npx react-native run-ios for React Native 0.70.1/Xcode 14/Monterey M1:

The following build commands failed:
    SwiftEmitModule normal arm64 Emitting module for YogaKit (in target 'YogaKit' from project 'Pods')

However build in Xcode 14 went successfully without any error. Tried to exclude arm64 in Build Setting for DEBUG (currently is i386) and it didn’t fix. Also add the following block in pod file and didn’t fix as well:

   installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
      # some older pods don't support some architectures, anything over iOS 11 resolves that
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
      end
    end

3

Answers


  1. Check Xcode config for PROJECT and Pods:

    enter image description here

    enter image description here

    Or check directly the project.pbxproj file, you should have something like this for release or debug project configs:

    83CBBA211A601CBA00E9B192 /* Release */ = {
            isa = XCBuildConfiguration;
            baseConfigurationReference = 191954F424AC5C2600989E18 /* Config.xcconfig */;
    // ....
     "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "i386";
    

    and for Pods:

    "EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 i386";
    /* for Pods-PSG.debug.xcconfig or Pods-PSG.release.xcconfig */
    

    Having this config should allow Intel x86_64 based builds for simulators to avoid that error.

    My Podfile has also that setting:

    post_install do |installer|
      flipper_post_install(installer)
    
      react_native_post_install(installer)
      __apply_Xcode_12_5_M1_post_install_workaround(installer)
      
      // arm64 simulator EXCLUDED_ARCHS setting:
      installer.pods_project.build_configurations.each do |config|
        config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
      end
    
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
        end
      end
    end
    

    Notes:

    1. The above Podfile code was tested for RN 0.66 and RN 0.69
    2. The above was tested on X86_64 architectures. Please observe it targets only the simulators to exclude some unsupported libraries for current architecture. For M1 you need to check what are the architectures to be excluded and adjust Xcode and/or Podfile settings accordingly.

    You could also use some code to detect current architecture and exclude the ones that are not supported:

           #!/usr/bin/env ruby
           require 'xcodeproj'
           
           project = Xcodeproj::Project.open 'Foobar.xcodeproj'
           
           bad_arch = 'arm64'
           current_arch = `uname -m`.strip
           
           # xcode 12 on non-arm64 needs to exclude it for debug simulator builds so that we can test
           if current_arch != bad_arch
             project.build_settings('Debug')["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = bad_arch
             project.save
           end
    
    

    Source of above Podfile code:
    https://www.reddit.com/r/swift/comments/mw8djk/comment/gvi1rzh

    Login or Signup to reply.
  2. When I had this issue I could still build in xcode itself but not with npx react-native run-ios in the terminal. What did it for me was to reboot my macbook m1.

    Login or Signup to reply.
  3. If you have such an issue try to comment all "EXCLUDED_ARCHS" lines of code in your project.pbxproj.
    This helped me.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search