Skip to content

Instantly share code, notes, and snippets.

@thurt
Forked from andrey-skl/Readme.md
Created January 13, 2017 01:33
Show Gist options
  • Save thurt/7655508d804c36b1234fa0338e3673b8 to your computer and use it in GitHub Desktop.
Save thurt/7655508d804c36b1234fa0338e3673b8 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"
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment