react native project not build on MacBook M1
Asked Answered
F

3

2

I change my MacBook within new MacBook M1 pro and have issue an old project.

I work on old project where I use:

expo(version 40) which one is ejected and use

react-native(version ~0.63.4)

and when I try to build(command: react-native run-ios) project It return errors always, but when I make new project everything is Okay. I don't know what is problem.

Flagstone answered 2/12, 2021 at 18:42 Comment(0)
F
9

I found one solution.

Firstly I clean project and install everything again, then start building.

Commands:

watchman watch-del-all && rm -rf node_modules && rm -rf yarn.lock && rm -rf package-lock.json && yarn cache clean && yarn && cd ios && rm -rf Pods && rm -rf Podfile.lock && pod install && cd .. && cd android && ./gradlew clean && cd .. && yarn start --reset-cache

After that I start build with this command:

arch -x86_64 yarn run ios

or

arch -x86_64 react-native run-ios

Flagstone answered 2/12, 2021 at 18:42 Comment(3)
just stumbled upon your answer after almost giving up on running old react-native projects on my new m1. arch -x86_64 yarn ios was the solution! you saved my day (week)!!!Planetary
not working for m1 max, "error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app..."Hoad
try this command for pod file installation -> arch -x86_64 pod installFlagstone
A
3

How I resolved my issue, with M1 arm Mac

> arch -x86_64 expo init AwesomeProject
> cd AwesomeProject
> arch -x86_64 yarn
>arch -x86_64 yarn start

**Working :) **

Auriol answered 23/5, 2022 at 13:29 Comment(0)
E
0

Don't clean everything, removing yarn.lock and podfile.lock is not required. As this might upgrade the dependencies which might be required and would require testing.

I faced similar issues on M1 Mac. I am listing them down.

  1. Error: GET https://github.com/electron/electron/releases/download/v1.8.8/electron-v1.8.8-darwin-arm64.zip returned 404

Solution this was to upgrade react-devtools in your package file

 "react-devtools": "^4.23.0", // Upgrade to the latest one
  1. Then make sure your paths are setup correctly. I added one additionally as it was required for me. You can update path if required as suggested below. I am using z Shell so suggesting zshrc

echo 'export PATH=/usr/bin/node:$PATH' >> ~/.zshrc

  1. Since mine was an existing project and has x86 libs. I use Rosetta for Xcode. By right clicking on xcode => Get Info => Select Open using Rosetta.

Finally

brew install cocoapods // To install compatible arch for m1
arch -x86_64 gem install ffi. // Install the ffi Ruby gem for Apple’s Rosetta 2
arch -x86_64 pod install
arch -x86_64 yarn run ios
Eccentric answered 25/2, 2022 at 8:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.