Sitemap

80+ Commands To Bookmark For React Native

8 min readOct 8, 2024

A list of commands with explanations every React Native developer should bookmark for the future.

Press enter or click to view image in full size
Photo by Christin Hume on Unsplash

Since React Native is multi-platform, we will divide this into four sections: iOS, Android, Expo, and React Native core commands.

1. iOS Commands

Commands to help you with the iOS development and Xcode:

1. Open the project in Xcode

open ios/YourApp.xcworkspace
  • Opens the iOS project in Xcode, allowing you to build, run, and modify native iOS configurations.

2. Install iOS dependencies

pod-install
  • Installs CocoaPods dependencies listed in the Podfile for the iOS project. It ensures all required libraries are installed.

3. Update iOS dependencies

pod repo update
  • Updates the local CocoaPods repository to retrieve the latest versions of dependencies before installation. When to use: If you encounter an error about missing pod versions or outdated dependencies.

4. Reintegrate iOS dependencies

pod reingrate
  • Reintegrates CocoaPods dependencies into your Xcode workspace, which is useful when issues arise with installed libraries.

5. Install pods from Podfile and update the local CocoaPods repository

pod install - repo-update
  • Installs the necessary CocoaPods while updating the local repository to the latest version.

6. Clean iOS build

xcodebuild clean -workspace ios/YourApp.xcworkspace -scheme YourApp -configuration Debug
  • Cleans the iOS build artifacts, which is often necessary when encountering build errors.

7. Archive iOS App (submission to the App Store):

xcodebuild -workspace ios/YourApp.xcworkspace -scheme YourApp -sdk iphoneos -configuration Release archive -archivePath ios/build/YourApp.xcarchive
  • Prepares the iOS app for submission to the App Store by creating an archived build.

8. Xcode Build

xcodebuild -workspace ios/YourApp.xcworkspace -scheme YourApp -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build
  • Builds the iOS app for development and testing on an iOS simulator.

9. Delete Pods

rm -rf ios/Pods
  • Removes all installed CocoaPods from the Pods folder.

10. Delete Podfile.lock

rm -rf ios/Pods
  • Deletes the Podfile.lock, which is useful for resetting your pod setup before reinstalling dependencies.

11. Clean derivated data

rm -rf ~/Library/Developer/Xcode/DerivedData/*
  • Cleans Xcode’s cached data, which is useful for resolving compilation issues or stale cache problems.

12. List connected devices

xcrun xctrace list devices
  • Lists all connected iOS devices and simulators for testing or debugging.

13. Clean Xcode build cache

rm -rf ~/Library/Developer/Xcode/DerivedData/*
  • Cleans the Xcode build cache to resolve potential caching issues during builds.

14. Pod update

cd ios && pod update
  1. Updates installed CocoaPods to the latest versions.

2. Android

Native commands to help you with the Android development:

14. Run the app on Android

react-native run-android
  • Builds and runs the Android app on a connected device or emulator. This is the most common command to launch the app during development.

15. List of open devices

adb devices
  • Lists all Android devices and emulators that are connected to your system. Useful to check if a device is ready for testing.

16. Clean Gradle

./gradlew clean
  • Cleans the Gradle build files, clearing any temporary files or cached data that might cause issues with the build process.

17. Build Gradle

./gradlew build
  • Compiles and builds the Android project using Gradle. This prepares the app for deployment or testing.

18. Debug connected devices

adb logcat
  • Streams logs from connected Android devices or emulators. Useful for debugging and monitoring app performance or errors.

19. Debug connected devices (filter by app)

adb logcat | grep com.app.name
  • Filters the log output to display logs specific to your app’s package name. This helps you pinpoint issues related to your app more quickly.

20. Build APK for testing

cd android && ./gradlew assembleDebug
  • This command generates a debug APK that can be installed on devices for testing purposes. This APK contains extra debugging information.

21. Generate a signed app for production

cd android && ./gradlew assembleRelease
  • Builds a signed release APK suitable for submission to the Google Play Store. This APK is optimized for performance and security.

22. Open Android emulator

emulator -avd <your_avd_name>
  • Launches the specified Android emulator using the name of your Android Virtual Device (AVD).

23. Open Android Logcat for debugging

adb logcat *:S ReactNative:V ReactNativeJS:V
  • Opens Android’s logcat for detailed logging but only shows logs related to React Native and JavaScript activity to help filter out noise and focus on relevant logs.

24. Uninstall app from Android

adb uninstall com.projectname
  • Uninstall your app from a connected Android device or emulator using the app’s package name.

25. Install .apk on device

adb install path_to_apk.apk
  • Installs a specific APK file on a connected Android device or emulator for testing or debugging purposes.

26. Run adb reverse (for device debugging):

adb reverse tcp:8081 tcp:8081
  • Sets up reverse port forwarding, allowing the device to connect to the local development server (Metro) running on your machine. Useful for debugging on real devices.

27. Clear Android build cache:

cd android && ./gradlew cleanBuildCache
  1. Clears the Android build cache. This can resolve issues caused by stale build files or cache corruption when building the Android project.

3. React Native

React Native CLI commands:

28. Initialize a new project

react-native init ProjectName
  • Initializes a brand new React Native project. This sets up the project structure and installs all necessary dependencies.

29. Run the project on iOS

react-native run-ios

30. Run the project on Android

react-native run-android

31. Run the project on a specific iOS simulator

react-native run-ios --simulator="iPhone 14"

32. Install project dependencies

npm install or yarn install
  • Installs all the project’s dependencies listed in package.json

33. Link dependencies (for versions below 0.60):

react-native link
  • Before React Native 0.60, linking was required to connect native modules to the iOS and Android projects.

34. Unlink a package

react-native unlink package-name
  • This command removes the link to a specific package from your project. It works only on RN 0.60 and earlier.

35. Open DevTools

react-devtools
  • Opens React Native DevTools and provides tools to inspect and debug React components.

36. Check for outdated packages

npm outdated or yarn outdated
  • Checks for outdated dependencies in the project. It shows which packages have newer versions available.

37. Upgrade the project to the latest version

react-native upgrade
  • Updates the React Native version in your project to the latest stable release. Don't use for larger and projects with multiple native libraries.

38. Start a metro bundler

npm start
  • Starts the Metro bundler, which bundles the JavaScript code for the app and makes it available for development. It is essential for running and testing your app.

39. Clear cache & start Metro Bundler

npm start --reset-cache

40. Run React Native in release mode (iOS)

react-native run-ios --configuration Release
  • Builds and runs the iOS app in release mode, creating an optimized build for production testing.

41. Run React Native in release mode (Android)

react-native run-android --variant=release
  • Builds and runs the Android app in release mode, optimized for production. This is used for final testing before releasing the app.

42. Run Yest test

npm test or yarn test
  • The command that runs all the yest tests in your project

43. Run Eslint

eslint .
  • Runs ESLint to check your codebase for potential errors, warnings, or style issues based on the rules defined in the ESLint configuration file.

44. Fix Eslint issues

eslint . --fix
  • Auto fixes linting issues in your codebase based on the defined ESLint rules.

45. Run Prettier

prettier --write .
  • This command formats your code according to the rules defined in your Prettier configuration.

46. Run Detox (testing)

detox tes

4. Expo

Expo CLI commands:

47. Create a new Expo project

create-expo-app ProjectName

48. Installing Expo

yarn add expo
  • It adds Expo as a dependency to an existing project, which is useful when integrating Expo into an existing React Native CLI project.

49. Run Expo App (Android)

expo start --android

50. Run Expo App (iOS)

expo start --ios

51. Run Expo App

expo start --ios

52. Expo login

expo login -h
  • Logs into your Expo account from the command line, required for publishing apps or using Expo services.

53. Open project in Expo DevTools

 expo start --dev-client
  • Starts the Expo project with DevTools, allowing you to debug the app in a custom development client.

54. Clear Expo app

expo eject
  • Ejects the Expo, allowing for full native customization.

55. Publishing Expo

expo publish
  • Publishes the Expo project to the cloud, allowing users to access it via a permanent URL or the Expo Go app.

56. Build a project for production (iOS)

expo build:ios
  • Builds the app for production on iOS, generating a .ipa file for submission to the App Store.

57. Build a project for production (Android)

expo build:android
  • Builds the app for production on Android, generating an .apk or .aab file for submission to the Google Play Store.

58. Create Expo development build

expo run:ios or expo run:android
  • Creates a local development build of the Expo app to be run.

59. Build for web

expo build:web
  • Builds the project for the web platform, creating optimized assets and bundles for a web deployment.

60. Optimize assets for production

expo-optimize
  • Optimizes images and other static assets to reduce file sizes for faster load times in production.

61. Clear cache and start Expo

expo start -c
  • Clears the Expo cache and starts the development server, useful when encountering issues caused by cached data.

62. Install specific Expo package

expo install package-name
  • Installs a specific Expo-compatible package and ensures compatibility with the current SDK.

63. Upgrade Expo SDK

expo upgrade
  • Upgrades the Expo project to the latest SDK, ensuring compatibility with the latest features.

64. Configure iOS credentials

expo credentials:manager
  • Manages iOS credentials (provisioning profiles and certificates).

65. Check project configuration (app.json)

expo config
  • Displays the current configuration for the project as defined in app.json.

66. Run Expo Diagnostics

expo diagnostics
  • Gathers diagnostic information about your project setup, which is useful for troubleshooting issues or reporting bugs.

67. Expo Logout

expo logout
  • Logs out of the Expo account in the command line.

68. Build an app for EAS (Expo Application Services):

eas build
  • Builds the app using EAS, which supports iOS and Android building without the need to eject or leave the Expo.

69. Check your project’s build status (EAS):

eas build:status
  • Shows the status of the recent builds for your project in Expo Application Services.

70. Configure EAS for automatic app signing:

eas config
  • Configures the EAS service to handle your app's automatic signing and simplifies the submission process for iOS and Android.

71. View Expo logs:

expo logs
  • Displays logs generated by Expo, which help debug the Expo app during development.

72. Install Expo Updates:

npm install -g expo-cli or yarn global add expo-cli
  • Installs or updates the Expo CLI globally, ensuring you work with the latest version.

73. List All Available Expo Commands:

expo --help
  • Displays a list of all available Expo CLI commands with descriptions for each.

74. Check Expo's release notes:

expo release-notes
  • Displays the release notes for the latest Expo SDK, including updates and changes.

75. Check & update project dependencies

expo doctor
  • This command checks and update your project’s dependencies to ensure they are compatible with the current Expo version.

76. Open Expo Documentation

expo docs

77. Configure OTA (Over The Air) updates:

expo publish --release-channel <channel>
  • Publishes an Over The Air (OTA) update to a specific release channel, allowing your app to receive updates without requiring a full app store submission.

78. Run app on specific release channel

expo start --release-channel <channel-name>
  • Runs the Expo app on a specific release channel, which is useful for testing different app versions.

79. Roll back to the previous update

expo publish:rollback
  • Rolls back the app to the previous OTA update, undoing the most recent changes.

80. Test deep-linking in the Expo project

expo start --scheme <your-scheme>
  • The command that tests deep linking for your Expo project by specifying a custom scheme to open the app.

81. Check the bundle size of an Expo project

expo bundle:analyze
  • Analyzes and provides a report on the bundle size, helping to optimize the app for faster load times.

82. Delete the Expo project from Expo's servers

expo delete
  • Command that will permanently delete the project from Expo’s servers, removing all published versions and data associated with it.

Happy coding! 🎉

--

--

Adnan Sahinovic
Adnan Sahinovic

Written by Adnan Sahinovic

I build and secure mobile apps at scale. Mobile tech lead, React Native community contributor, and Creator of rnsec - first security scanner for React Native