Skip to content

Commit 70a73a5

Browse files
hramosMorgan Pretty
authored andcommitted
Cleanup troubleshooting and debugging docs.
Summary: This is a followup to facebook#8010. Troubleshooting has been updated to list only those issues that may affect a user that is setting up their environment. Any issues related to day to day use have been moved or merged into a more relevant doc. Closes facebook#8254 Reviewed By: caabernathy Differential Revision: D3459018 Pulled By: JoelMarcey fbshipit-source-id: dd76097af34bd33dda376fab39fb0f71061ef3e4
1 parent e81a7bf commit 70a73a5

File tree

5 files changed

+61
-82
lines changed

5 files changed

+61
-82
lines changed

docs/Debugging.md

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,54 @@ permalink: docs/debugging.html
77
next: testing
88
---
99

10-
## In-app Errors and Warnings
11-
12-
Errors and warnings are displayed inside your app in development builds.
13-
14-
### Errors
15-
16-
In-app errors are displayed in a full screen alert with a red background inside your app. This screen is known as a RedBox. You can use `console.error()` to manually trigger one.
17-
18-
### Warnings
19-
20-
Warnings will be displayed on screen with a yellow background. These alerts are known as YellowBoxes. Click on the alerts to show more information or to dismiss them.
21-
22-
As with a RedBox, you can use `console.warn()` to trigger a YellowBox.
23-
24-
YellowBoxes can be disabled during development by using `console.disableYellowBox = true;`. Specific warnings can be ignored programmatically by setting an array of prefixes that should be ignored: `console.ignoredYellowBox = ['Warning: ...'];`
25-
26-
> RedBoxes and YellowBoxes are automatically disabled in release (production) builds.
27-
2810
## Accessing the In-App Developer Menu
2911

30-
You can access the developer menu by shaking your device. 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.
12+
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.
13+
14+
![](img/DeveloperMenu.png)
3115

3216
> The Developer Menu is disabled in release (production) builds.
3317
3418
## Reloading JavaScript
3519

3620
Selecting `Reload` from the Developer Menu will reload the JavaScript that powers your application. You can also press `Command⌘ + R` in the iOS Simulator, or press `R` twice on Android emulators.
3721

22+
> If you are using a Dvorak/Colemak layout, use the `Command⌘ + P` keyboard shortcut to reload the simulator.
23+
3824
You will need to rebuild your app for changes to take effect in certain situations:
3925

4026
* You have added new resources to your native app's bundle, such as an image in `Images.xcassets` on iOS or in `res/drawable` folder on Android.
4127
* You have modified native code (Objective-C/Swift on iOS or Java/C++ on Android).
4228

29+
> If the `Command⌘ + R` keyboard shortcut does not seem to reload the iOS Simulator, go to the Hardware menu, select Keyboard, and make sure that "Connect Hardware Keyboard" is checked.
30+
4331
### Automatic reloading
4432

4533
You may enable Live Reload to automatically trigger a reload whenever your JavaScript code changes.
4634

4735
Live Reload is available on iOS via the Developer Menu. On Android, select "Dev Settings" from the Developer Menu and enable "Auto reload on JS change".
4836

37+
## In-app Errors and Warnings
38+
39+
Errors and warnings are displayed inside your app in development builds.
40+
41+
### Errors
42+
43+
In-app errors are displayed in a full screen alert with a red background inside your app. This screen is known as a RedBox. You can use `console.error()` to manually trigger one.
44+
45+
### Warnings
46+
47+
Warnings will be displayed on screen with a yellow background. These alerts are known as YellowBoxes. Click on the alerts to show more information or to dismiss them.
48+
49+
As with a RedBox, you can use `console.warn()` to trigger a YellowBox.
50+
51+
YellowBoxes can be disabled during development by using `console.disableYellowBox = true;`. Specific warnings can be ignored programmatically by setting an array of prefixes that should be ignored: `console.ignoredYellowBox = ['Warning: ...'];`
52+
53+
> RedBoxes and YellowBoxes are automatically disabled in release (production) builds.
54+
4955
## Accessing logs
5056

51-
To view detailed logs on iOS, open your app in Xcode, then Build and Run your app on a device or the iPhone Simulator. The console should appear automatically after the app launches.
57+
To view detailed logs on iOS, open your app in Xcode, then Build and Run your app on a device or the iPhone Simulator. The console should appear automatically after the app launches. If your app is failing to build, check the Issues Navigator in Xcode.
5258

5359
Run `adb logcat *:S ReactNative:V ReactNativeJS:V` in a terminal to display the logs for an Android app running on a device or an emulator.
5460

@@ -68,6 +74,8 @@ On Android 5.0+ devices connected via USB, you can use the [`adb` command line t
6874

6975
Alternatively, select `Dev Settings` from the Developer Menu, then update the `Debug server host for device` setting to match the IP address of your computer.
7076

77+
> If you run into any issues, it may be possible that one of your Chrome extensions is interacting in unexpected ways with the debugger. Try disabling all of your extensions and re-enabling them one-by-one until you find the problematic extension.
78+
7179
### Debugging using a custom JavaScript debugger
7280

7381
To use a custom JavaScript debugger in place of Chrome Developer Tools, set the `REACT_DEBUGGER` environment variable to a command that will start your custom debugger. You can then select `Debug JS Remotely` from the Developer Menu to start debugging.

docs/QuickStart-GettingStarted.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ Congratulations! You've successfully run and modified your first React Native ap
282282

283283
## Common Followups
284284

285+
- Learn how to access the Developer Menu, reload your JavaScript, access logs, and more in the [Debugging guide](docs/debugging.html#content).
286+
285287
<block class="mac ios" />
286288

287289
- If you want to run on a physical device, see the [Running on iOS Device page](docs/running-on-device-ios.html#content).
@@ -292,15 +294,17 @@ Congratulations! You've successfully run and modified your first React Native ap
292294

293295
<block class="mac ios android" />
294296

295-
- If you run into any issues getting started, see the [Troubleshooting](docs/troubleshooting.html#content) and [Debugging](docs/debugging.html#content) pages.
297+
- If you run into any issues getting started, see the [Troubleshooting](docs/troubleshooting.html#content) page.
296298

297299
<block class="windows linux android" />
298300

299301
## Common Followups
300302

303+
- Learn how to access the Developer Menu, reload your JavaScript, access logs, and more in the [Debugging guide](docs/debugging.html#content).
304+
301305
- If you want to run on a physical device, see the [Running on Android Device page](docs/running-on-device-android.html#content).
302306

303-
- If you run into any issues getting started, see the [Troubleshooting](docs/troubleshooting.html#content) and [Debugging](docs/debugging.html#content) pages.
307+
- If you run into any issues getting started, see the [Troubleshooting](docs/troubleshooting.html#content) page.
304308

305309
<script>
306310
// Convert <div>...<span><block /></span>...</div>

docs/RunningOnDeviceIOS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Note that running on device requires [Apple Developer account](https://developer
1111

1212
## Accessing development server from device
1313

14-
You can iterate quickly on device using development server. To do that, your laptop and your phone have to be on the same wifi network.
14+
You can iterate quickly on device using development server. Ensure that you are on the same WiFi network as your computer.
1515

1616
1. Open `AwesomeApp/ios/AwesomeApp/AppDelegate.m`
1717
2. Change the IP in the URL from `localhost` to your laptop's IP. On Mac, you can find the IP address in System Preferences / Network.

docs/Troubleshooting.md

Lines changed: 26 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -6,69 +6,51 @@ category: Quick Start
66
permalink: docs/troubleshooting.html
77
---
88

9-
## Cmd-R does not reload the simulator
10-
Enable iOS simulator's "Connect hardware keyboard" from menu Hardware > Keyboard menu.
9+
These are some common issues you may run into while setting up React Native. If you encounter something that is not listed here, try [searching for the issue in GitHub](https://github.com/facebook/react-native/issues/).
1110

12-
![Keyboard Menu](https://cloud.githubusercontent.com/assets/1388454/6863127/03837824-d409-11e4-9251-e05bd31d978f.png)
11+
### Port already in use
1312

13+
The React Native packager runs on port 8081. If another process is already using that port (such as McAfee Antivirus on Windows), you can either terminate that process, or change the port that the packager uses.
1414

15-
If you are using a non-QWERTY/AZERTY keyboard layout you can use the `Hardware > Shake Gesture` to bring up the dev menu and click "Refresh". Alternatively, you can hit `Cmd-P` on Dvorak/Colemak layouts to reload the simulator.
15+
#### Terminating a process on port 8081
1616

17-
You can use Cmd+M on Android to bring up the dev menu.
17+
Run the following command on a Mac to find the id for the process that is listening on port 8081:
1818

19-
## Port already in use red-screen
20-
![red-screen](https://cloud.githubusercontent.com/assets/602176/6857442/63fd4f0a-d3cc-11e4-871f-875b0c784611.png)
21-
22-
23-
Something is probably already running on port 8081. You can either kill it or try to change which port the packager is listening to.
24-
25-
##### Kill process on port 8081
2619
`$ sudo lsof -n -i4TCP:8081 | grep LISTEN`
2720

28-
then
21+
Then run the following to terminate the process:
2922

30-
`$ kill -9 <cma process id>`
23+
`$ kill -9 <PID>`
3124

25+
#### Using a port other than 8081
3226

33-
##### Change the port in Xcode
34-
Edit `AppDelegate.m` to use a different port.
35-
```
36-
// OPTION 1
37-
// Load from development server. Start the server from the repository root:
38-
//
39-
// $ npm start
40-
//
41-
// To run on device, change `localhost` to the IP address of your computer, and make sure your computer and
42-
// iOS device are on the same Wi-Fi network.
43-
jsCodeLocation = [NSURL URLWithString:@"http://localhost:9381/index.ios.bundle"];
44-
```
27+
You can configure the packager to use a port other than 8081 by using the `port` parameter:
4528

29+
`$ react-native start --port=8088`
4630

47-
## Watchman took too long to load
48-
Permission settings prevent Watchman from loading. A recent update solves this, get a HEAD install of Watchman if you are experiencing this error.
31+
You will also need to update your applications to load the JavaScript bundle from the new port.
32+
33+
To change the port used by an iOS application, edit the `AppDelegate.m` file in the `ios` folder. Scroll down to the line where the bundle location is defined, and replace 8081 with the new port.
4934

5035
```
51-
brew uninstall watchman
52-
brew install --HEAD watchman
36+
jsCodeLocation = [NSURL URLWithString:@"http://localhost:8088/index.ios.bundle"];
5337
```
5438

55-
## NPM locking error
39+
### NPM locking error
40+
41+
If you encounter an error such as "npm WARN locking Error: EACCES" while using the React Native CLI, try running the following:
5642

57-
If in the `react-native init <project>` phase you saw npm fail with "npm WARN locking Error: EACCES" then try the following:
5843
```
5944
sudo chown -R $USER ~/.npm
6045
sudo chown -R $USER /usr/local/lib/node_modules
6146
```
6247

63-
## Debugging in Chrome hangs and/or does not work well
64-
It is possible that one of your Chrome extensions is interacting in unexpected ways with the debugger. If you are having this issue, try disabling all of your extensions and re-enabling them one-by-one until you find the problematic extension.
48+
### Missing libraries for React
6549

66-
## Xcode Build Failures
50+
If you added React Native manually to your project, make sure you have included all the relevant dependencies that you are using, like `RCTText.xcodeproj`, `RCTImage.xcodeproj`. Next, the binaries built by these dependencies have to be linked to your app binary. Use the `Linked Frameworks and Binaries` section in the Xcode project settings. More detailed steps are here: [Linking Libraries](docs/linking-libraries-ios.html#content).
6751

68-
To see the exact error that is causing your build to fail, go into the Issues Navigator in the left sidebar.
69-
70-
##### React libraries missing
7152
If you are using CocoaPods, verify that you have added React along with the subspecs to the `Podfile`. For example, if you were using the `<Text />`, `<Image />` and `fetch()` APIs, you would need to add these in your `Podfile`:
53+
7254
```
7355
pod 'React', :path => '../node_modules/react-native', :subspecs => [
7456
'RCTText',
@@ -77,46 +59,31 @@ pod 'React', :path => '../node_modules/react-native', :subspecs => [
7759
'RCTWebSocket',
7860
]
7961
```
80-
Next, make sure you have run `pod install` and that a `Pods/` directory has been created in your project with React installed. CocoaPods will instruct you to use the generated `.xcworkspace` file henceforth to be able to use these installed dependencies.
8162

82-
If you are adding React manually, make sure you have included all the relevant dependencies, like `RCTText.xcodeproj`, `RCTImage.xcodeproj` depending on the ones you are using. Next, the binaries built by these dependencies have to be linked to your app binary. Use the `Linked Frameworks and Binaries` section in the Xcode project settings. More detailed steps are here: [Linking Libraries](docs/linking-libraries-ios.html#content).
63+
Next, make sure you have run `pod install` and that a `Pods/` directory has been created in your project with React installed. CocoaPods will instruct you to use the generated `.xcworkspace` file henceforth to be able to use these installed dependencies.
8364

84-
##### Argument list too long: recursive header expansion failed
65+
#### Argument list too long: recursive header expansion failed
8566

8667
In the project's build settings, `User Search Header Paths` and `Header Search Paths` are two configs that specify where Xcode should look for `#import` header files specified in the code. For Pods, CocoaPods uses a default array of specific folders to look in. Verify that this particular config is not overwritten, and that none of the folders configured are too large. If one of the folders is a large folder, Xcode will attempt to recursively search the entire directory and throw above error at some point.
8768

8869
To revert the `User Search Header Paths` and `Header Search Paths` build settings to their defaults set by CocoaPods - select the entry in the Build Settings panel, and hit delete. It will remove the custom override and return to the CocoaPod defaults.
8970

90-
## Unable to connect to development server
91-
92-
##### iOS
93-
Ensure that you are on the same WiFi network as your computer. If you're using a cell data plan, your phone can't access your computer's local IP address.
94-
95-
##### Android
96-
You need to run `adb reverse tcp:8081 tcp:8081` to forward requests from the device to your computer. This works only on Android 5.0 and newer.
71+
### No transports available
9772

98-
## Module that uses `WebSocket` (such as Firebase) throws an exception
73+
React Native implements a polyfill for WebSockets. These [polyfills](https://github.com/facebook/react-native/blob/master/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js) are initialized as part of the react-native module that you include in your application through `import React from 'react-native'`. If you load another module that requires WebSockets, such as [Firebase](https://github.com/facebook/react-native/issues/3645), be sure to load/require it after react-native:
9974

100-
React Native implements a polyfill for WebSockets. These polyfills are initialized as part of the react-native module that you include in your application through `import React from 'react-native'`. If you load another module that requires WebSockets, be sure to load/require it after react-native.
101-
102-
So:
10375
```
10476
import React from 'react-native';
10577
import Firebase from 'firebase';
10678
```
10779

108-
Requiring firebase *before* react-native will result in a 'No transports available' redbox.
109-
110-
Discovered thanks to issue [#3645](https://github.com/facebook/react-native/issues/3645). If you're curious, the polyfills are set up in [InitializeJavaScriptAppEngine.js](https://github.com/facebook/react-native/blob/master/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js).
111-
112-
11380
## Shell Command Unresponsive Exception
11481

115-
If you encounter:
82+
If you encounter a ShellCommandUnresponsiveException exception such as:
11683

11784
```
11885
Execution failed for task ':app:installDebug'.
11986
com.android.builder.testing.api.DeviceException: com.android.ddmlib.ShellCommandUnresponsiveException
12087
```
12188

122-
Try downgrading your Gradle version to 1.2.3 in `<project-name>/android/build.gradle` (https://github.com/facebook/react-native/issues/2720)
89+
Try [downgrading your Gradle version to 1.2.3](https://github.com/facebook/react-native/issues/2720) in `android/build.gradle`.
48.5 KB
Loading

0 commit comments

Comments
 (0)