开始

开始

需求

1、React Native现在只支持OS X系统

2、Homebrew

  安装Homebrew:ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"(详情请戳标题)

3、安装Node.js

  1. Node.js4.0或者更新
    • 安装nvm参考its setup instructions here
    • vi ~/.bash_profile
        添加:source /Users/dujie/.nvm/nvm.sh(需要注意的是将该目录改成自己的目录/Users/dujie)
    • nvm install node && nvm alias default node
    • 或者直接只用brew install node(安装Node)
  2. brew install watchman
  3. brew install flow

时常运行brew update && brew upgrade来保证本地是最新的项目

4、Xcode6.3或者更高

快速开始

1、npm命令安装React Native 的CLI工具:npm install -g react-native-cli  

2、创建项目(系统根目录下):react-native init AwesomeProject(AwesomeProject 是工程名,注:真的是等了好长时间,还以为是哪里出错了,做好心理准备时间有点长)

To run the iOS app:

  • $ cd AwesomeProject
  • Open ios/AwesomeProject.xcodeproj and hit run in Xcode.
  • Open index.ios.js in your text editor of choice and edit some lines.
  • Hit ⌘-R in your iOS simulator to reload the app and see your change!

To run the Android app:

  • $ cd AwesomeProject
  • $ react-native run-android
  • Open index.android.js in your text editor of choice and edit some lines.
  • Press the menu button (F2 by default, or ⌘-M in Genymotion) and select Reload JS to see your change!
  • Run adb logcat *:S ReactNative:V ReactNativeJS:V in a terminal to see your app's logs

Note: If you are using a device, see the Running on Device page.

Congratulations! You've successfully run and modified your first React Native app.

If you run into any issues getting started, see the troubleshooting page.

给工程添加安卓支持

  1. Update the react-native dependency in your package.json file to the latest version
  2. $ npm install
  3. $ react-native android

 

  

 
 
 
 
 
 
posted @ 2015-10-10 12:07  zhiupping8  阅读(138)  评论(0编辑  收藏  举报