Skip to content

Instantly share code, notes, and snippets.

@dongyuwei
Last active November 19, 2016 03:08
Show Gist options
  • Save dongyuwei/d5c2c60a446eed9b05890fbc83ea5ff8 to your computer and use it in GitHub Desktop.
Save dongyuwei/d5c2c60a446eed9b05890fbc83ea5ff8 to your computer and use it in GitHub Desktop.
setup react-native mobile app development on Mac

How to start?

  1. install nvm: wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
  2. nvm install 7.0.0
  3. nvm use 7.0.0 # or you can download and install https://npm.taobao.org/mirrors/node/latest-v7.x/node-v7.0.0.pkg
  4. npm install --registry=https://registry.npm.taobao.org
  5. nvm use 7.0.0
  6. export PATH=node_modules/.bin:$PATH

Below is detail info about dev/debug on iOS and android

dev and debug on ios emulator

  1. make sure your Xcode and the commandline tools installed and selected correctly.
  2. react-native run-ios.
  3. Press command + control + Z in Xcode Simulator, choose Debug JS Remotely.
  4. goto http://localhost:8081/debugger-ui, press command + option + J to open Chrome developer tools.
  5. you can use the traditional console.log api and see the log now.
  6. ref: https://facebook.github.io/react-native/docs/debugging.html

run app on android emulator

  1. brew install android-sdk
  2. export ANDROID_HOME=/usr/local/opt/android-sdk # in ~/.bashrc
  3. export PATH=$PATH:${ANDROID_HOME}/tools
  4. source /usr/local/etc/bash_completion.d/adb-completion.bash
  5. use android sdk and andoid avd to install sdk and create avd.
  6. android list targets
  7. android create avd -n test-android-6 -t android-23 --abi default/x86_64
  8. emulator -avd test-android-6
  9. sign key for andoid
    1. see the config content in ./android/keystores/debug.keystore.properties
    2. keytool -genkey -v -keystore ~/.android/debug.keystore -keyalg RSA -keysize 2048 -validity 10000 -alias androiddebugkey
    3. input android as key-store-password
    4. cd android && ./gradlew signingReport
    5. cd ..
  10. react-native run-android
@dongyuwei
Copy link
Author

.gitignore

.idea
node_modules
*.log
.DS_Store
tmp/*
dump.rdb
*.pid
ios/build/
android/build/
android/.gradle/
android/app/build/
ios/foo-app.xcodeproj/project.xcworkspace/
ios/foo-app.xcodeproj/xcuserdata/

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