You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: docs/Debugging.md
+12-12
Original file line number
Diff line number
Diff line change
@@ -14,15 +14,15 @@ React Native supports a few keyboard shortcuts in the iOS Simulator. They are de
14
14
15
15
## Accessing the In-App Developer Menu
16
16
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.
18
18
19
19

20
20
21
21
> The Developer Menu is disabled in release (production) builds.
22
22
23
23
## Reloading JavaScript
24
24
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.
26
26
27
27
### Automatic reloading
28
28
@@ -61,7 +61,7 @@ In CI/Xcode, YellowBoxes can also be disabled by setting the `IS_TESTING` enviro
61
61
62
62
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).
63
63
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.
65
65
66
66
> 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.
67
67
@@ -75,7 +75,7 @@ The debugger will receive a list of all project roots, separated by a space. For
75
75
76
76
## React Developer Tools
77
77
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:
79
79
80
80
```
81
81
npm install -g react-devtools
@@ -91,11 +91,11 @@ react-devtools
91
91
92
92
It should connect to your simulator within a few seconds.
93
93
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.
95
95
96
96
### Integration with React Native Inspector
97
97
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:
99
99
100
100

101
101
@@ -109,7 +109,7 @@ You can choose "Hide Inspector" in the same menu to exit this mode.
109
109
110
110
When debugging JavaScript in Chrome, you can inspect the props and state of the React components in the browser console.
111
111
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.
113
113
114
114
Make sure that the dropdown in the top left corner of the Chrome console says `debuggerWorker.js`. **This step is essential.**
115
115
@@ -138,8 +138,6 @@ You can enable a performance overlay to help you debug performance problems by s
138
138
139
139
## Accessing console logs
140
140
141
-
Note: if you're using Create React Native App, these already appear in the same terminal output as the packager.
142
-
143
141
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:
144
142
145
143
```
@@ -149,9 +147,11 @@ $ react-native log-android
149
147
150
148
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.
151
149
150
+
> If you're using Create React Native App, console logs already appear in the same terminal output as the packager.
151
+
152
152
## Debugging on a device with Chrome Developer Tools
153
153
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.
155
155
156
156
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.
157
157
@@ -201,8 +201,8 @@ Alternatively, select "Dev Settings" from the Developer Menu, then update the "D
201
201
202
202
4. Run ```react-native run-android ```
203
203
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").
205
205
206
206
## Debugging native code
207
207
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.
Copy file name to clipboardexpand all lines: docs/GettingStarted.md
+48-35
Original file line number
Diff line number
Diff line change
@@ -133,13 +133,19 @@ Congratulations! You've successfully run and modified your first React Native ap
133
133
134
134
## Now what?
135
135
136
-
- If you're curious to learn more about React Native, continue on
137
-
to the [Tutorial](docs/tutorial.html).
138
-
139
136
- 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.
140
137
141
138
- 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.
142
139
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
+
143
149
### Caveats
144
150
145
151
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
384
390
385
391
<blockclass="native mac windows linux android" />
386
392
387
-
#### 3. Set up the ANDROID_HOME environment variable
393
+
#### 3. Configure the ANDROID_HOME environment variable
388
394
389
395
The React Native tools require some environment variables to be set up in order to build apps with native code.
390
396
391
-
<blockclass="native mac android" />
397
+
<blockclass="native mac linux android" />
398
+
399
+
Add the following lines to your `$HOME/.bash_profile` config file:
392
400
393
-
Add the following lines to your `~/.profile` (or equivalent) config file:
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
-
405
409
<blockclass="native linux android" />
406
410
407
-
Add the following lines to your `~/.profile` (or equivalent) config file:
Type `. ~/.profile` to load the config into your current shell.
417
+
<blockclass="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.
416
420
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**.
418
424
419
425
<blockclass="native windows android" />
420
426
@@ -475,7 +481,7 @@ Either way, you will need to prepare the device to run Android apps for developm
475
481
476
482
### Using a physical device
477
483
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).
479
485
480
486
### Using a virtual device
481
487
@@ -538,6 +544,12 @@ You should see your new app running in the iOS Simulator shortly.
538
544
539
545
`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/).
540
546
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
+
541
553
<blockclass="native mac windows linux android" />
542
554
543
555
## 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
563
575
564
576
`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/).
565
577
578
+
> If you can't get this to work, see the [Troubleshooting](docs/troubleshooting.html#content) page.
579
+
566
580
<blockclass="native mac ios android" />
567
581
568
582
### Modifying your app
@@ -572,12 +586,12 @@ Now that you have successfully run the app, let's modify it.
572
586
<blockclass="native mac ios" />
573
587
574
588
- 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!
576
590
577
591
<blockclass="native mac android" />
578
592
579
593
- 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!
581
595
582
596
<blockclass="native windows linux android" />
583
597
@@ -586,7 +600,7 @@ Now that you have successfully run the app, let's modify it.
586
600
Now that you have successfully run the app, let's modify it.
587
601
588
602
- 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!
590
604
591
605
<blockclass="native mac ios android" />
592
606
@@ -600,32 +614,31 @@ Congratulations! You've successfully run and modified your first React Native ap
600
614
601
615
### That's it!
602
616
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.
- If you're curious to learn more about React Native, continue on
612
-
to the [Tutorial](docs/tutorial.html).
623
+
## Now what?
613
624
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!
615
626
616
627
- 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).
617
628
618
-
<blockclass="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).
619
631
620
-
## Now What?
632
+
<blockclass="native windows linux mac android" />
621
633
622
-
- If you're curious to learn more about React Native, continue on
623
-
to the [Tutorial](docs/tutorial.html).
634
+
## Now what?
624
635
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!
626
637
627
638
- 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).
628
639
640
+
If you're curious to learn more about React Native, continue on
0 commit comments