Skip to content

Commit 674a642

Browse files
hramosfacebook-github-bot
authored andcommitted
Expand Getting Started, Debugging, Running on Device guides.
Summary: - Clarified PATH instructions. - Expand running on device instructions for iOS. - Add Android production release instructions. - Misc. cleanup. Closes #14142 Differential Revision: D5116072 Pulled By: hramos fbshipit-source-id: d95274f61a9b26282977d43d3307b726a6b93704
1 parent a790430 commit 674a642

6 files changed

+107
-69
lines changed

docs/Debugging.md

+12-12
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ React Native supports a few keyboard shortcuts in the iOS Simulator. They are de
1414

1515
## Accessing the In-App Developer Menu
1616

17-
You can access the developer menu by shaking your device or by selecting "Shake Gesture" inside the Hardware menu in the iOS Simulator. You can also use the **`Command`**`` + **`D`** keyboard shortcut when your app is running in the iPhone Simulator, or **`Command`**`` + **`M`** when running in an Android emulator.
17+
You can access the developer menu by shaking your device or by selecting "Shake Gesture" inside the Hardware menu in the iOS Simulator. You can also use the `⌘D` keyboard shortcut when your app is running in the iOS Simulator, or `⌘M` when running in an Android emulator.
1818

1919
![](img/DeveloperMenu.png)
2020

2121
> The Developer Menu is disabled in release (production) builds.
2222
2323
## Reloading JavaScript
2424

25-
Instead of recompiling your app every time you make a change, you can reload your app's JavaScript code instantly. To do so, select "Reload" from the Developer Menu. You can also press **`Command`**`` + **`R`** in the iOS Simulator, or press **`R`** twice on Android emulators.
25+
Instead of recompiling your app every time you make a change, you can reload your app's JavaScript code instantly. To do so, select "Reload" from the Developer Menu. You can also press `⌘R` in the iOS Simulator, or tap `R` twice on Android emulators.
2626

2727
### Automatic reloading
2828

@@ -61,7 +61,7 @@ In CI/Xcode, YellowBoxes can also be disabled by setting the `IS_TESTING` enviro
6161

6262
To debug the JavaScript code in Chrome, select "Debug JS Remotely" from the Developer Menu. This will open a new tab at [http://localhost:8081/debugger-ui](http://localhost:8081/debugger-ui).
6363

64-
Select `Tools → Developer Tools` from the Chrome Menu to open the [Developer Tools](https://developer.chrome.com/devtools). You may also access the DevTools using keyboard shortcuts (**`Command`**`` + **`Option`**`` + **`I`** on Mac, **`Ctrl`** + **`Shift`** + **`I`** on Windows). You may also want to enable [Pause On Caught Exceptions](http://stackoverflow.com/questions/2233339/javascript-is-there-a-way-to-get-chrome-to-break-on-all-errors/17324511#17324511) for a better debugging experience.
64+
Select `Tools → Developer Tools` from the Chrome Menu to open the [Developer Tools](https://developer.chrome.com/devtools). You may also access the DevTools using keyboard shortcuts (`⌘⌥I` on macOS, `Ctrl` `Shift` `I` on Windows). You may also want to enable [Pause On Caught Exceptions](http://stackoverflow.com/questions/2233339/javascript-is-there-a-way-to-get-chrome-to-break-on-all-errors/17324511#17324511) for a better debugging experience.
6565

6666
> Note: the React Developer Tools Chrome extension does not work with React Native, but you can use its standalone version instead. Read [this section](docs/debugging.html#react-developer-tools) to learn how.
6767
@@ -75,7 +75,7 @@ The debugger will receive a list of all project roots, separated by a space. For
7575
7676
## React Developer Tools
7777

78-
With React Native 0.43 or higher, you can use [the standalone version of React Developer Tools](https://github.com/facebook/react-devtools/tree/master/packages/react-devtools) to debug the React component hierarchy. To use it, install the `react-devtools` package globally:
78+
You can use [the standalone version of React Developer Tools](https://github.com/facebook/react-devtools/tree/master/packages/react-devtools) to debug the React component hierarchy. To use it, install the `react-devtools` package globally:
7979

8080
```
8181
npm install -g react-devtools
@@ -91,11 +91,11 @@ react-devtools
9191

9292
It should connect to your simulator within a few seconds.
9393

94-
> Note: if you prefer to avoid global installations, you can add `react-devtools` as a project dependency. With Yarn, you can run `yarn add --dev react-devtools`, and then run `yarn react-devtools` from your project folder to open the DevTools. With npm, you can run `npm install --save-dev react-devtools`, add `"react-devtools": "react-devtools"` to the `scripts` section in your `package.json`, and then run `npm run react-devtools` from your project folder to open the DevTools.
94+
> Note: if you prefer to avoid global installations, you can add `react-devtools` as a project dependency. Add the `react-devtools` package to your project using `npm install --save-dev react-devtools`, then add `"react-devtools": "react-devtools"` to the `scripts` section in your `package.json`, and then run `npm run react-devtools` from your project folder to open the DevTools.
9595
9696
### Integration with React Native Inspector
9797

98-
You can open the [in-app developer menu](#accessing-the-in-app-developer-menu) and choose "Show Inspector". It will bring up an overlay that lets you tap on any UI element and see information about it:
98+
Open the in-app developer menu and choose "Show Inspector". It will bring up an overlay that lets you tap on any UI element and see information about it:
9999

100100
![React Native Inspector](img/Inspector.gif)
101101

@@ -109,7 +109,7 @@ You can choose "Hide Inspector" in the same menu to exit this mode.
109109

110110
When debugging JavaScript in Chrome, you can inspect the props and state of the React components in the browser console.
111111

112-
First, follow the [instructions for debugging in Chrome](docs/debugging.html#chrome-developer-tools) to open the Chrome console.
112+
First, follow the instructions for debugging in Chrome to open the Chrome console.
113113

114114
Make sure that the dropdown in the top left corner of the Chrome console says `debuggerWorker.js`. **This step is essential.**
115115

@@ -138,8 +138,6 @@ You can enable a performance overlay to help you debug performance problems by s
138138

139139
## Accessing console logs
140140

141-
Note: if you're using Create React Native App, these already appear in the same terminal output as the packager.
142-
143141
You can display the console logs for an iOS or Android app by using the following commands in a terminal while the app is running:
144142

145143
```
@@ -149,9 +147,11 @@ $ react-native log-android
149147

150148
You may also access these through `Debug → Open System Log...` in the iOS Simulator or by running `adb logcat *:S ReactNative:V ReactNativeJS:V` in a terminal while an Android app is running on a device or emulator.
151149

150+
> If you're using Create React Native App, console logs already appear in the same terminal output as the packager.
151+
152152
## Debugging on a device with Chrome Developer Tools
153153

154-
Note: if you're using Create React Native App, this is configured for you already.
154+
> If you're using Create React Native App, this is configured for you already.
155155
156156
On iOS devices, open the file [`RCTWebSocketExecutor.m`](https://github.com/facebook/react-native/blob/master/Libraries/WebSocket/RCTWebSocketExecutor.m) and change "localhost" to the IP address of your computer, then select "Debug JS Remotely" from the Developer Menu.
157157

@@ -201,8 +201,8 @@ Alternatively, select "Dev Settings" from the Developer Menu, then update the "D
201201

202202
4. Run ```react-native run-android ```
203203

204-
5. In a new chrome tab, open : ```chrome://inspect```, click on 'Inspect device' (the one followed by "Powered by Stetho")
204+
5. In a new Chrome tab, open: ```chrome://inspect```, then click on 'Inspect device' (the one followed by "Powered by Stetho").
205205

206206
## Debugging native code
207207

208-
When working with native code (e.g. when writing native modules) you can launch the app from Android Studio or Xcode and take advantage of the debugging features (setup breakpoints, etc.) as you would in case of building a standard native app.
208+
When working with native code, such as when writing native modules, you can launch the app from Android Studio or Xcode and take advantage of the native debugging features (setting up breakpoints, etc.) as you would in case of building a standard native app.

docs/GettingStarted.md

+48-35
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,19 @@ Congratulations! You've successfully run and modified your first React Native ap
133133

134134
## Now what?
135135

136-
- If you're curious to learn more about React Native, continue on
137-
to the [Tutorial](docs/tutorial.html).
138-
139136
- Create React Native App also has a [user guide](https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/README.md) you can reference if you have questions specific to the tool.
140137

141138
- If you can't get this to work, see the [Troubleshooting](https://github.com/react-community/create-react-native-app/blob/master/react-native-scripts/template/README.md#troubleshooting) section in the README for Create React Native App.
142139

140+
If you're curious to learn more about React Native, continue on
141+
to the [Tutorial](docs/tutorial.html).
142+
143+
### Running your app on a simulator or virtual device
144+
145+
Create React Native App makes it really easy to run your React Native app on a physical device without setting up a development environment. If you want to run your app on the iOS Simulator or an Android Virtual Device, please refer to the instructions for building projects with native code to learn how to install Xcode and set up your Android development environment.
146+
147+
Once you've set these up, you can launch your app on on an Android Virtual Device by running `npm run android`, or on the iOS Simulator by running `npm run ios` (macOS only).
148+
143149
### Caveats
144150

145151
Because you don't build any native code when using Create React Native App to create a project, it's not possible to include custom native modules beyond the React Native APIs and components that are available in the Expo client app.
@@ -384,37 +390,37 @@ Finally, click "Apply" to download and install the Android SDK and related build
384390

385391
<block class="native mac windows linux android" />
386392

387-
#### 3. Set up the ANDROID_HOME environment variable
393+
#### 3. Configure the ANDROID_HOME environment variable
388394

389395
The React Native tools require some environment variables to be set up in order to build apps with native code.
390396

391-
<block class="native mac android" />
397+
<block class="native mac linux android" />
398+
399+
Add the following lines to your `$HOME/.bash_profile` config file:
392400

393-
Add the following lines to your `~/.profile` (or equivalent) config file:
401+
<block class="native mac android" />
394402

395403
```
396-
export ANDROID_HOME=${HOME}/Library/Android/sdk
397-
export PATH=${PATH}:${ANDROID_HOME}/tools
398-
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
404+
export ANDROID_HOME=$HOME/Library/Android/sdk
405+
export PATH=$PATH:$ANDROID_HOME/tools
406+
export PATH=$PATH:$ANDROID_HOME/platform-tools
399407
```
400408

401-
Type `source ~/.profile` to load the config into your current shell.
402-
403-
> Please make sure you export the correct path for `ANDROID_HOME`. If you installed the Android SDK using Homebrew, it would be located at `/usr/local/opt/android-sdk`. You can find the actual location of the SDK in the Android Studio "Preferences" dialog, under **Appearance & Behavior****System Settings****Android SDK**.
404-
405409
<block class="native linux android" />
406410

407-
Add the following lines to your `~/.profile` (or equivalent) config file:
408-
409411
```
410-
export ANDROID_HOME=${HOME}/Android/Sdk
411-
export PATH=${PATH}:${ANDROID_HOME}/tools
412-
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
412+
export ANDROID_HOME=$HOME/Android/Sdk
413+
export PATH=$PATH:$ANDROID_HOME/tools
414+
export PATH=$PATH:$ANDROID_HOME/platform-tools
413415
```
414416

415-
Type `. ~/.profile` to load the config into your current shell.
417+
<block class="native mac linux android" />
418+
419+
> `.bash_profile` is specific to `bash`. If you're using another shell, you will need to edit the appropriate shell-specific config file.
416420
417-
> Please make sure you export the correct path for `ANDROID_HOME` if you did not install the Android SDK using Android Studio. You can find the actual location of the SDK in the Android Studio "Preferences" dialog, under **Appearance & Behavior****System Settings****Android SDK**.
421+
Type `source $HOME/.bash_profile` to load the config into your current shell. Verify that ANDROID_HOME has been added to your path by running `echo $PATH`.
422+
423+
> Please make sure you use the correct Android SDK path. You can find the actual location of the SDK in the Android Studio "Preferences" dialog, under **Appearance & Behavior****System Settings****Android SDK**.
418424
419425
<block class="native windows android" />
420426

@@ -475,7 +481,7 @@ Either way, you will need to prepare the device to run Android apps for developm
475481

476482
### Using a physical device
477483

478-
If you have a physical Android device, you can use it for development in place of an AVD by plugging it in to your computer using a USB cable and [enabling USB debugging](https://developer.android.com/training/basics/firstapp/running-app.html). You can then proceed to the next step.
484+
If you have a physical Android device, you can use it for development in place of an AVD by plugging it in to your computer using a USB cable and following the instructions [here](docs/running-on-device.html).
479485

480486
### Using a virtual device
481487

@@ -538,6 +544,12 @@ You should see your new app running in the iOS Simulator shortly.
538544

539545
`react-native run-ios` is just one way to run your app. You can also run it directly from within Xcode or [Nuclide](https://nuclide.io/).
540546

547+
> If you can't get this to work, see the [Troubleshooting](docs/troubleshooting.html#content) page.
548+
549+
### Running on a device
550+
551+
The above command will automatically run your app on the iOS Simulator by default. If you want to run the app on an actual physical iOS device, please follow the instructions [here](docs/running-on-device.html).
552+
541553
<block class="native mac windows linux android" />
542554

543555
## Running your React Native application
@@ -563,6 +575,8 @@ If everything is set up correctly, you should see your new app running in your A
563575

564576
`react-native run-android` is just one way to run your app - you can also run it directly from within Android Studio or [Nuclide](https://nuclide.io/).
565577

578+
> If you can't get this to work, see the [Troubleshooting](docs/troubleshooting.html#content) page.
579+
566580
<block class="native mac ios android" />
567581

568582
### Modifying your app
@@ -572,12 +586,12 @@ Now that you have successfully run the app, let's modify it.
572586
<block class="native mac ios" />
573587

574588
- Open `index.ios.js` in your text editor of choice and edit some lines.
575-
- Hit `Command⌘ + R` in your iOS Simulator to reload the app and see your changes!
589+
- Hit `R` in your iOS Simulator to reload the app and see your changes!
576590

577591
<block class="native mac android" />
578592

579593
- Open `index.android.js` in your text editor of choice and edit some lines.
580-
- Press the `R` key twice or select `Reload` from the Developer Menu to see your changes!
594+
- Press the `R` key twice or select `Reload` from the Developer Menu (`⌘M`) to see your changes!
581595

582596
<block class="native windows linux android" />
583597

@@ -586,7 +600,7 @@ Now that you have successfully run the app, let's modify it.
586600
Now that you have successfully run the app, let's modify it.
587601

588602
- Open `index.android.js` in your text editor of choice and edit some lines.
589-
- Press the `R` key twice or select `Reload` from the Developer Menu to see your changes!
603+
- Press the `R` key twice or select `Reload` from the Developer Menu (`⌘M`) to see your changes!
590604

591605
<block class="native mac ios android" />
592606

@@ -600,32 +614,31 @@ Congratulations! You've successfully run and modified your first React Native ap
600614

601615
### That's it!
602616

603-
Congratulations! You've successfully run and modified a React Native app.
617+
Congratulations! You've successfully run and modified your first React Native app.
604618

605619
<center><img src="img/react-native-congratulations.png" width="150"></img></center>
606620

607621
<block class="native mac ios" />
608622

609-
## Now What?
610-
611-
- If you're curious to learn more about React Native, continue on
612-
to the [Tutorial](docs/tutorial.html).
623+
## Now what?
613624

614-
- If you can't get this to work, see the [Troubleshooting](docs/troubleshooting.html#content) page.
625+
- Turn on [Live Reload](docs/debugging.html#reloading-javascript) in the Developer Menu. Your app will now reload automatically whenever you save any changes!
615626

616627
- If you want to add this new React Native code to an existing application, check out the [Integration guide](docs/integration-with-existing-apps.html).
617628

618-
<block class="native windows linux mac android" />
629+
If you're curious to learn more about React Native, continue on
630+
to the [Tutorial](docs/tutorial.html).
619631

620-
## Now What?
632+
<block class="native windows linux mac android" />
621633

622-
- If you're curious to learn more about React Native, continue on
623-
to the [Tutorial](docs/tutorial.html).
634+
## Now what?
624635

625-
- If you can't get this to work, see the [Troubleshooting](docs/troubleshooting.html#content) page.
636+
- Turn on [Live Reload](docs/debugging.html#reloading-javascript) in the Developer Menu. Your app will now reload automatically whenever you save any changes!
626637

627638
- If you want to add this new React Native code to an existing application, check out the [Integration guide](docs/integration-with-existing-apps.html).
628639

640+
If you're curious to learn more about React Native, continue on
641+
to the [Tutorial](docs/tutorial.html).
629642

630643
<script>
631644
// Convert <div>...<span><block /></span>...</div>

0 commit comments

Comments
 (0)