react-native: Cannot debug JS remotely on iOS device
Description
Create app with react-native init myapp
Run the app in Xcode
with real iPhone as target, open up the developer menu and select debug js remotely
.
App screen on device now stuck at Loading from pre-bundler file...
In the debugger console log I can see an error:
GET file:///var/containers/Bundle/Application/FB3D960C-BF23-4F8A-B458-A9FFED6AFEF2/myapp.app/main.jsbundle net::ERR_FILE_NOT_FOUND
Additional Information
- React Native version: 0.44.2
- Platform: iOS device only, the exact same code works on all other debugging methods including android devices
- Development Operating System: OSX
- Dev tools: Xcode
Observations
- Both server and phone are connected to the same network
On device remote JS debugging
does not work withRCTWebSocketExecutor.m
set tolocalhost
orserver local ip
- With IP set to
localhost
, I get the usual red screen error warning I should change the IP inRCTWebSocketExecutor
- With IP set to
server local IP
, I don’t get the green progress bar when loading the app, instead I have a black bar with the textloading from pre-bundle file
, and it will just get stuck in here forever - No activity on the debugger window
- At this point, I can see and error log in the debugger console
GET file:///var/containers/Bundle/Application/FB3D960C-BF23-4F8A-B458-A9FFED6AFEF2/ttt.app/main.jsbundle net::ERR_FILE_NOT_FOUND
- Using the phone’s browser and navigate to http://server-local-ip:8081/debugger-proxy?role=proxy works
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 22
- Comments: 22 (2 by maintainers)
Here is a temporary work around for this issue.
Make sure you have a sim card in your iPhone. Turn on data and hotspot. Connect your iPhone to your Mac using the USB cable. On the Mac, connect to the iPhone’s hotspot. Clean project and run again You should now have the option to debug JS remotely on the dev menu.
update:
Using the suggestions in https://github.com/facebook/react-native/pull/14885 and a few google searches, I have managed to fixed this problem on our BT router. The problem was that some router blocks wildcard DNS binding which xip.io uses. The solution is to change the DNS of the connection on your Mac. You can also change the DNS on the router itself instead if you have access.
Steps:
+1 for 0.43 and 0.47. Infuriating– cannot test any iOS push notifications.
My workaround:
Cmd+Shift+K
)./build
folder in/ios
.I resolved my issue by cleaning Xcode project
Command-Option-Shift-K
and re-building to the physical iPhone target.+1 same issue React Native version: 0.45.1, Mac OS : 10.12.5
In my case, rm -rf node_modules , yarn again. It works.
Same issue on IOS Phone emulator with React Native version: 0.45.1, on macOS 10.12.5. The app crash if the remote debug is set to true. No problem on android, emulator and hardware device.
@gabceb Thanks! Looks like there is a new section in the 0.49 docs that deals with this problem. https://github.com/facebook/react-native/pull/14885