Quantcast
Channel: Recent Gists from badsyntax
Viewing all articles
Browse latest Browse all 31

Some tips to working with react-native 0.64 on an Apple M1 Silicon chip

$
0
0
react-native-apple-m1.md

My env:

  • cocoapods 1.10.1
  • xcode 12.4
  • macos big sur 11.2.3
  • react-native 0.64

iOS

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.

Ensure arm64 is excluded for the simulator build in the main project. Here's a reference:

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

post_installdo |installer|
  react_native_post_install(installer)installer.pods_project.targets.eachdo |target|
    target.build_configurations.eachdo |config|
      # Disable arm64 builds for the simulatorconfig.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]']='arm64'endendend

You'll need to re-install pods after making this change:

cd ios
rm -rf Pods Podfile.lock
pod install

Some libraries/pods will STILL have arch issues installing. You might get errors like missing compatible arch in /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.0/lib/ffi_c.bundle, in which you will have to use Rosetta:

sudo arch -x86_64 gem install ffi
arch -x86_64 pod install

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

Hermes

I couldn't get hermes to build. I think this will be fixed in react-native 0.65, see: facebook/hermes#475& react-native-community/releases#223

Android

I have no problems building the project but the emulator does not support arm64. There is an Android Emulator M1 Preview but it has a few restrictions, like not having a working browser. To workaround this you can use a physical device attached via usb.


Viewing all articles
Browse latest Browse all 31

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>