Skip to content

Instantly share code, notes, and snippets.

@andrey-skl
Last active October 9, 2019 13:42
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save andrey-skl/bc1e004fbbf91ba129ae to your computer and use it in GitHub Desktop.
Save andrey-skl/bc1e004fbbf91ba129ae to your computer and use it in GitHub Desktop.
How to compile and run react-native application from terminal

To run on ios:

  1. Install XCode (recommended) or XCode command line tools by xcode-select --install
  2. Into XCode settings, go to "Downloads" tab and download iOS 9.2 emulator
  3. Compile native app and run it on simulator via npm run ios

To run on Android:

  1. Set up Android environment
  2. Create emulator via npm run android-emulator-create
  3. Run emulator via npm run android-emulator
  4. Compile native code and run it on emulator via npm run android
{
...
"scripts": {
"start": "./node_modules/react-native-cli/index.js start",
"ios-build": "xcodebuild -project ios/YourAppName.xcodeproj -scheme YourAppName -sdk iphonesimulator -destination platform='iOS Simulator',name='iPhone 6 Plus' -derivedDataPath ios/build",
"ios-launch-sim": "xcrun instruments -w 'iPhone 5s (9.2)'",
"ios-install-app": "xcrun simctl install booted ios/build/Build/Products/Debug-iphonesimulator/YourAppName.app",
"ios-launch-installed": "xcrun simctl launch booted org.yourcompany.YourAppName",
"ios": "npm run ios-build && npm run ios-launch-sim || npm run ios-install-app && npm run ios-launch-installed",
"android": "./node_modules/react-native-cli/index.js run-android",
"android-emulator": "emulator -avd YourAppName -scale 0.4 -gpu on -memory 2048",
"android-emulator-create": "android create avd -n YourAppName -t 1 -b x86 --skin 1080x1920 --device 'Nexus 5'",
"android-emulator-delete": "android delete avd -n YourAppName"
}
...
}
@andrey-skl
Copy link
Author

For now react-native run-ios does the same thing

@GAVISHSETHI
Copy link

how to change ios devices??

@tmchale
Copy link

tmchale commented Nov 20, 2017

react-native run-ios --simulator="iPhone 7 Plus"

will run in 7+ simulator, for example

@thomazchamberlain
Copy link

You can use --device for running it on your device. For example react-native run-ios --device "Thomas Chamberlain's iPhone".

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