mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
5.5 KiB
5.5 KiB
id, title, original_id
| id | title | original_id |
|---|---|---|
| version-0.22-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:
cd AwesomeProject</code></li><li>Open <code>ios/AwesomeProject.xcodeproj</code> and hit run in Xcode.</li><li>Open <code>index.ios.js</code> in your text editor of choice and edit some lines.</li><li>Hit ⌘-R in your iOS simulator to reload the app and see your change!</li></ul><p><em>Note: If you are using an iOS device, see the <a href="docs/running-on-device-ios.html#content" target="_blank">Running on iOS Device page</a>.</em></p><p><strong>To run the Android app:</strong></p><ul><li><code>cd AwesomeProjectreact-native run-android</code></li><li>Open <code>index.android.js</code> in your text editor of choice and edit some lines.</li><li>Press the menu button (F2 by default, or ⌘-M in Genymotion) and select <em>Reload JS</em> to see your change!</li><li>Run <code>adb logcat *:S ReactNative:V ReactNativeJS:V</code> in a terminal to see your app's logs</li></ul><p><em>Note: If you are using an Android device, see the <a href="docs/running-on-device-android.html#content" target="_blank">Running on Android Device page</a>.</em></p><p>Congratulations! You've successfully run and modified your first React Native app.</p><p><em>If you run into any issues getting started, see the <a href="docs/troubleshooting.html#content" target="_blank">troubleshooting page</a>.</em></p><h2><a class="anchor" name="adding-android-to-an-existing-react-native-project"></a>Adding Android to an existing React Native project <a class="hash-link" href="docs/getting-started.html#adding-android-to-an-existing-react-native-project">#</a></h2><p>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:</p><ol><li>Update the <code>react-native</code> dependency in your <code>package.json</code> file to <a href="https://www.npmjs.com/package/react-native" target="_blank">the latest version</a></li><li><code>npm install$ react-native android