Skip to content

Instantly share code, notes, and snippets.

@Aung-Myint-Thein
Last active June 28, 2022 02:34
Show Gist options
  • Save Aung-Myint-Thein/f56b0252d99fd297ca47a82c8acb7cf2 to your computer and use it in GitHub Desktop.
Save Aung-Myint-Thein/f56b0252d99fd297ca47a82c8acb7cf2 to your computer and use it in GitHub Desktop.
General commands for React Native developers

For General

Clear watchman watches: watchman watch-del-all.

Delete the node_modules folder: rm -rf node_modules && npm install.

Reset Metro Bundler cache: rm -rf /tmp/metro-bundler-cache-* or npm start -- --reset-cache.

Remove haste cache: rm -rf /tmp/haste-map-react-native-packager-*.

When the VS Code Icon appears small in Dock: killall Dock

For iOS

If there are some issues with new library etc (especially after RN 0.60)

  1. Close Xcode and pack manger.
  2. Clear Xcode Cache

rm -rf ~/Library/Developer/Xcode/DerivedData

  1. Go into ios folder

cd ios

  1. Clear CocoaPods Cache

pod deintegrate && pod cache clean --all

rm -rf Podfile.lock

  1. Re-Install Pods

pod install

  1. The install can take now a veeery long time — if it seems to be stuck, you should re-setup cocoa with an update before installing again, as follows:

gem install cocoapods (you maybe have to use sudo)

then

pod repo remove master --verbose && pod setup --verbose && pod install --verbose

  1. then

pod install

On M1 machine

for homebrew users

step 1 brew install cocoapods

step 2 sudo arch -x86_64 gem install ffi

step 3 arch -x86_64 pod install

If you are setting up a new machine, you would need to do this first:

Command Line Tools

You will also need to install the Xcode Command Line Tools. Open Xcode, then choose "Preferences..." from the Xcode menu. Go to the Locations panel and install the tools by selecting the most recent version in the Command Line Tools dropdown.

How to set up environment

For Android

If a library messed up and you need to clean up,

cd android/

./gradlew clean cleanBuildCache

When trying to get a release apk and got an error,

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

When Google Sign In or Firebase error,

npx jetify Source

When Google Sign In gives an error (resources not found) in building release APK,

./gradlew app:assembleRelease instead of ./gradlew assembleRelease Source

Expo Updates

expo publish --release-channel <your-channel>

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