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.

Revisions

  1. @badsyntax badsyntax revised this gist May 15, 2021. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions react-native-apple-m1.md
    Original file line number Diff line number Diff line change
    @@ -28,6 +28,14 @@ post_install do |installer|
    end
    ```

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

    ```bash
    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:

    ```bash
  2. @badsyntax badsyntax revised this gist May 15, 2021. No changes.
  3. @badsyntax badsyntax revised this gist May 15, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion react-native-apple-m1.md
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ My env:
    - cocoapods 1.10.1
    - xcode 12.4
    - macos big sur 11.2.3
    - react 0.64
    - react-native 0.64

    ## iOS

  4. @badsyntax badsyntax revised this gist May 15, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions react-native-apple-m1.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ Ensure arm64 is excluded for the simulator build in the main project. Here's a r

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

    ```
    ```ruby
    post_install do |installer|
    react_native_post_install(installer)

    @@ -39,7 +39,7 @@ You won't be able to "Distribute" (create an .ipa from an archive build). You'll

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

    ```
    ```bash
    # Create the .ipa from the archive
    arch -x86_64 xcodebuild \
    -exportArchive \
  5. @badsyntax badsyntax revised this gist May 15, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion react-native-apple-m1.md
    Original file line number Diff line number Diff line change
    @@ -54,4 +54,4 @@ I couldn't get hermes to build. I think this will be fixed in react-native 0.65,

    # Android

    There is an [Android Emulator M1 Preview](https://github.com/google/android-emulator-m1-preview) but it has a few restrictions, like not having a working browser.
    I have no problems building the project but the emulator does not support arm64. There is an [Android Emulator M1 Preview](https://github.com/google/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.
  6. @badsyntax badsyntax revised this gist May 15, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion react-native-apple-m1.md
    Original file line number Diff line number Diff line change
    @@ -54,4 +54,4 @@ I couldn't get hermes to build. I think this will be fixed in react-native 0.65,

    # Android

    For android, there is an [Android Emulator M1 Preview](https://github.com/google/android-emulator-m1-preview) but it has a few restrictions, like not having a working browser.
    There is an [Android Emulator M1 Preview](https://github.com/google/android-emulator-m1-preview) but it has a few restrictions, like not having a working browser.
  7. @badsyntax badsyntax revised this gist May 15, 2021. 1 changed file with 9 additions and 2 deletions.
    11 changes: 9 additions & 2 deletions react-native-apple-m1.md
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,11 @@
    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
    - react 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.

    @@ -47,4 +48,10 @@ arch -x86_64 xcodebuild \
    -exportOptionsPlist ExportOptions.plist
    ```

    ## Hermes

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

    # Android

    For android, there is an [Android Emulator M1 Preview](https://github.com/google/android-emulator-m1-preview) but it has a few restrictions, like not having a working browser.
  8. @badsyntax badsyntax revised this gist May 8, 2021. No changes.
  9. @badsyntax badsyntax revised this gist May 8, 2021. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions react-native-apple-m1.md
    Original file line number Diff line number Diff line change
    @@ -47,6 +47,4 @@ arch -x86_64 xcodebuild \
    -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](https://github.com/google/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!
    For android, there is an [Android Emulator M1 Preview](https://github.com/google/android-emulator-m1-preview) but it has a few restrictions, like not having a working browser.
  10. @badsyntax badsyntax revised this gist May 8, 2021. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion react-native-apple-m1.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,11 @@ My env:
    - 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](https://github.com/react-native-community/rn-diff-purge/blob/45a22384013841340108a8f5a519b2d5d403452e/RnDiffApp/ios/RnDiffApp.xcodeproj/project.pbxproj#L564) for the debug and release builds but not for the pods, so we need to do the same for the pods:
    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:

    <img src="https://user-images.githubusercontent.com/102141/117538263-49856e00-affd-11eb-84d1-7eb521ec705f.png" />

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

  11. @badsyntax badsyntax revised this gist Apr 16, 2021. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions react-native-apple-m1.md
    Original file line number Diff line number Diff line change
    @@ -23,6 +23,13 @@ post_install do |installer|
    end
    ```

    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:

    ```bash
    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:
  12. @badsyntax badsyntax revised this gist Apr 15, 2021. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions react-native-apple-m1.md
    Original file line number Diff line number Diff line change
    @@ -39,5 +39,3 @@ arch -x86_64 xcodebuild \
    For android, I don't really have many good tips. The android emulators didn't work and i tried the [Android Emulator M1 Preview](https://github.com/google/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!

    (Edit: Why is the code formatting broken on mobile??)
  13. @badsyntax badsyntax created this gist Apr 15, 2021.
    43 changes: 43 additions & 0 deletions react-native-apple-m1.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,43 @@
    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](https://github.com/react-native-community/rn-diff-purge/blob/45a22384013841340108a8f5a519b2d5d403452e/RnDiffApp/ios/RnDiffApp.xcodeproj/project.pbxproj#L564) 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](https://github.com/google/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!

    (Edit: Why is the code formatting broken on mobile??)