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.
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
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 :) **
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.
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
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
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
Related
Screenshot of npx react-native doctor:
As you can see, the iOS is all green ticks. I npm start in a terminal tab to run react native metro server. I then open another terminal and npm run ios Yes, the simulator opens straight away, but then I get a long error: https://pastebin.com/6bFTMDTr
I cd ios then pod install and got this:
Anyone have any idea?
Have you tried installing the pod dependency manually?
$ cd iOS && pod install
upd.
Looks like you haven't installed Ruby
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install ruby
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
after that install a watchman depend
$ brew update
$ brew install watchman
upd2.
1) brew reinstall cocoapods
(error message will come up regarding linking)
2) brew link --overwrite cocoapods
(to fix the link)
Everytime i run my App with "XCode" it failed with the error "34 duplicate symbols for architecture arm64".
I use the xcode version "14.1". I cannot find a solution for this problem.
Additional: I use the library "react-native-beacons-manager" and add "libRniBeacon.a" in "link Binary With Libraries".
Does anybody know how i can solve this error?
Try this:
rm -rf node_modules
cd ios
rm -rf Podfile.lock Pods
removed derived data
Quit Xcode
cd ..
npm install
cd ios
pod install
run the project from XCODE
I tried to run an existing react-native project on mac to create ios build but i've been getting into an unusual error as mentioned below. I don't know what RCT-Folly does as i am new to react-native but i think the error is related to RCT-Folly, I tried many other stack answers but couldn't solve it
Here is a picture of the error
I have tried the other solution like creating a fresh projects and copying files, also tried reinstalling cocoapods,
If there is some other thread that you guys think i should try please let me know
Stuck at this for more than 3 days now!
Update:
After downgrading react native version it is now showing this error:
CompileC /Users/admin/Desktop/MTM/mindToMindfull\ 2/ios/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-Core.build/Objects-normal/x86_64/RCTJSThread.o /Users/admin/Desktop/MTM/mindToMindfull\ 2/node_modules/react-native/React/Base/RCTJSThread.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (in target 'React-Core' from project 'Pods')
RCT-Folly is an iOS Cocoapod library. Try cleaning your project first. From the project root, run (for Yarn)
watchman watch-del-all && rm -f yarn.lock; rm -rf node_modules,
then
yarn
cd ios && rm -rf ~/Library/Caches/CocoaPods Pods ~/Library/Developer/Xcode/DerivedData/; rm Podfile.lock; pod deintegrate; pod setup; pod install && cd ..
yarn ios
I haven't used npm in awhile. But for 2 and 4, use npm install and npx react-native run-ios
Solved by downgrading react-native version 0.66.4
then installing pods and build was a success.
when I use 'react-native run-ios', there is some error, 'boost/operators.hpp' file not found.
I can not build and run my project:
react-native-cli: 2.0.1
react-native: 0.59.9
npm: 6.9.0
yarn: 1.16.0
node: v12.4.0
os: macos 10.14.5
xcode: 10.2.1
▸ Compiling JSIDynamic.cpp
❌ /Users/lidongbo/WorkBentch/ReactNative/AwesomeProject/node_modules/react-native/React/../third-party/folly-2018.10.22.00/folly/dynamic.h:63:10: 'boost/operators.hpp' file not found
#include <boost/operators.hpp>
^
▸ Analyzing JSCRuntime.cpp
▸ Analyzing jsi.cpp
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, by opening AwesomeProject.xcodeproj
project can build and run.
If you get this issue in react-native-reanimated after upgrading to react-native 0.66 update your react-native-reanimated in package.json
Try "react-native-reanimated": "2.3.0-beta.2"
Don't forget to run yarn install or npm install to update your packages. Also do a pod install for ios and restart your server instance .
EDIT:
Support for react-native#0.66 has been officially added by react-native-reanimated#2.2.3 It is less buggy and a lot more issues have been solved.
Also check issue on github.
This might due to incomplete pods install - try deleting ios/Pods folder and run pod install under ios.
An alternative error for the same issue that I encountered was:
ios/Pods/boost-for-react-native/boost/operators.hpp:97:10: 'boost/config.hpp' file not found
To fix it, you need to clear cocoa pods and cache and re-install.
Delete cocoa pods cache: rm -r ~/Library/Caches/CocoaPods
Delete the Pods folder and the Podfile.lock usually located in <project_root>/ios.
Reinstall pods: pod update
You must delete cache from wherever ios concerns; Here's the process I do to clear its cache:
Delete npm cache: npm cache clean --force
Delete All ios temp files: cd ios && rm -r Pods/ Podfile.lock {yourProject}.xcworkspace
Clear Cocoapods Cache: rm -r ~/Library/Caches/CocoaPods
now install pods via npx: cd .. && npx pod-install
So I was also getting the error boost/operators.hpp file not found but my issue was from using :path instead of :podspec in my Podfile. I'm working on an integrated RN app inside of a Native iOS app, so I was manually adding the pods to the Podfile (something I will not do from now on).
pod 'boost', :path => ...
instead of
pod 'boost', :podspec => ...
It might not be the most common fix but hoping it helps someone.
I resolve the problem.
boost_1_63_0.tar.gz
double-conversion-1.1.6.tar.gz
folly-2018.10.22.00.tar.gz
glog-0.3.5.tar.gz
These files are not completely downloaded due to network reasons.
The file url is :
{your proejct}/node_modules/react-native/scripts/ios-install-third-party.sh at lowest line.
When I upgraded RN 0.64 -> 0.66, the following helped me:
Delete cocoa pods cache: rm -r ~/Library/Caches/CocoaPods
Delete the Pods folder and the Podfile.lock usually located in <project_root>/ios
Delete Pod folder in <project_root>/ios
yarn add react-native-reanimated#2.2.3
pod install
How to clean react native project?
Is there any way to clean react native project as we can clean xcode project?
Any help will be appreciated!
A react-native Project is about one XCode Project and one Android Project. (for pure js code, there's no need to do clean)
So, what you need would be
Clean XCode Project with
cd ios
xcodebuild clean
And then clean Android Project with
cd android
./gradlew clean
You can simply write a batch file for it.
For android project
cd android &&./gradlew clean && cd ../
For iOS project
cd ios && xcodebuild clean && cd ../
If you need build clean again and again then add this scripts in the package.json file like this
scripts: {
"clean:android": "cd android && ./gradlew clean && cd ../",
"clean:ios": "cd ios && xcodebuild clean && cd ../",
}
Then run for android
yarn clean:android
And run for iOS
yarn clean:ios
For Android
cd android
gradlew clean
For IOS
cd ios
xcodebuild clean
Delete node modules and
npm ci
react-native link
followed by
react-native start --reset-cache
React Native clean-project is now the best and easiest way to do deal with react-native artifacts and cleanup. Since it's automatically detected by react-native, it becomes its own command in react-native.
$ yarn add -D react-native-clean-project
$ react-native clean-project
this script will clean the Android and IOS build cache, then removes node modules and caches, and reinstall the react native project.
# rm -rf $HOME/.gradle/caches/
cd android && ./gradlew cleanBuildCache
cd ..
cd ios && pod cache clean --all && rm -rf build
cd ..
rm -rf node_modules
yarn cache clean --force
yarn install
cd ios && pod install
To reset the iOS simulator and erase all simulator data, focus on the simulator then go to Hardware -> Erase All Content and Settings
To reset the Android emulator and erase all data, open Android Studio then goes to menu Tools -> AVD Manager, then click the dropdown menu on the selected simulator and click on wipe data.
More useful cleaner scripts. Seperating modules cleaning & native cleaning, based on the other great answers:
"scripts": {
"npm:clean": "rm -rf node_modules && npm cache clean && npm install"
"yarn:clean": "rm -rf node_modules && yarn cache clean --force && yarn install"
"android:clean": "cd android && ./gradlew clean && ./gradlew cleanBuildCache && cd ..",
"ios:clean": "cd ios && xcodebuild clean && rm -rf ~/Library/Caches/CocoaPods && rm -rf Pods && rm -rf ~/Library/Developer/Xcode/DerivedData/* && pod cache clean --all && pod deintegrate && pod setup && pod install && cd ..",
}
To reset react-native specific cache, run:
npm start -- --reset-cache
if in package.json you have
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
}
I added the following scripts to my package.json
scripts: {
....
"clean:android": "echo 'require(\"child_process\").execSync(\"cd android; ./gradlew clean\", {stdio: \"inherit\"})' | node ",
"clean:ios": "echo 'require(\"child_process\").execSync(\"cd ios; xcodebuild clean\", {stdio: \"inherit\"})' | node ",
"clean": "npm run clean:android && npm run clean:ios",
....
}
now you can clean android
npm run clean:android
clean ios
npm run clean:ios
clean both
npm run clean
React and node specific cleaning:
Remove node_modules to avoid inconsitence which may appear somehow rarely:
rm -rf node_modules
(reinstall if need with npm or yarn)
Clean npm cache if npm is used
npm cache clean
Clean react temp files:
rm -rf $TMP/react*
Clean the Android Project with:
cd android/
gradlew clean
remove android folder
run
react-native upgrade
then
react-native run-android