Skip to content

Instantly share code, notes, and snippets.

@Eric013
Forked from badsyntax/react-native-apple-m1.md
Created December 1, 2022 20:58
Show Gist options
  • Select an option

  • Save Eric013/8bf9226d5bbefe1f4d9ec1ec723f6b06 to your computer and use it in GitHub Desktop.

Select an option

Save Eric013/8bf9226d5bbefe1f4d9ec1ec723f6b06 to your computer and use it in GitHub Desktop.
Some tips to working with react-native 0.64 on an Apple M1 Silicon chip

I knew I'd be taking a risk getting the M1 Macbook so here's some tips/learnings.

My env:

  • cocoapods 1.10.1
  • xcode 12.4
  • macos big sur 11.2.3

The iOS simulator build won't "just work". If you get errors like ld: library not found for... or swift compiler errors, then you need to disable arm64 for the simulator build. ReactNative 0.64 added this change for the debug and release builds but not for the pods, so we need to do the same for the pods:

In Podfile, set EXCLUDED_ARCHS[sdk=iphonesimulator*] = 'arm64' for pods:

post_install do |installer|
  react_native_post_install(installer)

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      # Disable arm64 builds for the simulator
      config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
    end
  end
end

You won't be able to "Distribute" (create an .ipa from an archive build). You'll get an error like "IPA processing failed". This seems to be a bug with xcode 12.4. You will need to open XCode with Rosetta to fix this.

If you're using xcodebuild to generate an .ipa, you need to prepend arch -x86_64 to the command:

# Create the .ipa from the archive
arch -x86_64 xcodebuild \
  -exportArchive \
  -archivePath MyApp.xcarchive \
  -exportPath MyAppExported \
  -exportOptionsPlist ExportOptions.plist

For android, I don't really have many good tips. The android emulators didn't work and i tried the Android Emulator M1 Preview but it has many restrictions that prevented me from using it. I see now it's been added to the SDK Manager so perhaps they've made further updates. I will try it again when I have some time. I've been using my Windows laptop for Android dev.

Hopefully this is helpful to some. Please share any tips you might have!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment