5.6 KiB
id, title, original_id
| id | title | original_id |
|---|---|---|
| version-0.24-getting-started | getting-started | getting-started |
Getting Started # | Edit on GitHub |
Requirements #
- OS X - This guide assumes OS X which is needed for iOS development.
- Homebrew is the recommended way to install Watchman and Flow.
- Install Node.js 4.0 or newer.
- Install nvm with its setup instructions here. Then run
nvm install node && nvm alias default node, which installs the latest version of Node.js and sets up your terminal so you can run it by typingnode. With nvm you can install multiple versions of Node.js and easily switch between them. - New to npm?
- Install nvm with its setup instructions here. Then run
brew install watchman. We recommend installing watchman, otherwise you might hit a node file watching bug.brew install flow, if you want to use flow.
We recommend periodically running brew update && brew upgrade to keep your programs up-to-date.
iOS Setup #
Xcode 7.0 or higher is required. It can be installed from the App Store.
Android Setup #
To write React Native apps for Android, you will need to install the Android SDK (and an Android emulator if you want to work on your app without having to use a physical device). See Android setup guide for instructions on how to set up your Android environment.
NOTE: There is experimental Windows and Linux support for Android development.
Quick start #
Install the React Native command line tools:
npm install <span class="token operator">-</span>g react<span class="token operator">-</span>native<span class="token operator">-</span>cli</div><p><strong>NOTE</strong>: If you see the error, <code>EACCES: permission denied</code>, please run the command: <code>sudo npm install -g react-native-cli</code>.</p><p>Create a React Native project:</p><div class="prism language-javascript"> react-native init AwesomeProjectTo run the iOS app:
OR opencd AwesomeProject</code></li><li><code>react-native run-iosios/AwesomeProject.xcodeprojand hit "Run" button in Xcode- Open
index.ios.jsin your text editor of choice and edit some lines. - Hit ⌘-R in your iOS simulator to reload the app and see your change!
Note: If you are using an iOS device, see the Running on iOS Device page.
To run the Android app:
cd AwesomeProject</code></li><li><code>react-native run-android- Open
index.android.jsin 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:Vin a terminal to see your app's logs
Note: If you are using an Android device, see the Running on Android 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.
Adding Android to an existing React Native project #
If you already have a (iOS-only) React Native project and want to add Android support, you need to execute the following commands in your existing project directory:
- Update the
react-nativedependency in yourpackage.jsonfile to the latest version npm install</code></li><li><code>react-native android