react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Open Debugger in iOS simulator not working in RN 0.70.0

Open rstor1 opened this issue 2 years ago • 76 comments

Description

I started the basic AwesomeProject from the getting started in the docs and found that the Open Debugger is not working. Actually, I am unable to debug in multiple ways (safari, standalone devtools, launch.json from React Native Tools in vscode). Is this a known issue? It was working with 0.69:

Version

0.70.0

Output of npx react-native info

info Fetching system and libraries information... System: OS: macOS 12.5.1 CPU: (4) x64 Intel(R) Core(TM) i5-6287U CPU @ 3.10GHz Memory: 602.00 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v16.13.2/bin/yarn npm: 8.18.0 - ~/.nvm/versions/node/v16.13.2/bin/npm Watchman: 2022.08.29.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5 Android SDK: Not Found IDEs: Android Studio: Not Found Xcode: 13.4.1/13F100 - /usr/bin/xcodebuild Languages: Java: 17.0.2 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.0 => 0.70.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

In terminal run: npx react-native init AwesomeProject

In terminal run: npx react-native start

In vscode run: npx react-native run-ios

Once ios simulator(iPhone 13, ios 15.5) opens do CMD + D on the simulator to open the menu.

Click Open Debugger

Snack, code example, screenshot, or link to a repository

Screen Shot 2022-09-06 at 6 06 16 PM

rstor1 avatar Sep 06 '22 22:09 rstor1

quick question do you ran it with hermes enabled on Podfile ?

Bayramito avatar Sep 06 '22 22:09 Bayramito

quick question do you ran it with hermes enabled on Podfile ?

Podfile shows: :hermes_enabled => true

rstor1 avatar Sep 06 '22 22:09 rstor1

Got the same error after I just created a new project. Setting :hermes_enabled => false resolves the problem. I disabled Flipper as well, not sure if that had any effect.

cuongvoong avatar Sep 07 '22 05:09 cuongvoong

Got the same error after I just created a new project. Setting :hermes_enabled => false resolves the problem. I disabled Flipper as well, not sure if that had any effect.

This approacb may cause to not use all benefits of the new architecture

Bayramito avatar Sep 07 '22 06:09 Bayramito

The approaches of debugging you have tried are likely for the JavaScriptCore engine and not the Hermes engine which is the default in 0.70.0. Hermes directly implements the Chrome inspector protocol.

See Debugging JS on Hermes using Google Chrome's DevTools for debugging on Hermes.

For VSCode you should use the Debug iOS Hermes - Experimental launch configuration and not the Debug iOS launch configuration.

justin-tay avatar Sep 07 '22 06:09 justin-tay

The approaches of debugging you have tried are likely for the JavaScriptCore engine and not the Hermes engine which is the default in 0.70.0. Hermes directly implements the Chrome inspector protocol.

See Debugging JS on Hermes using Google Chrome's DevTools for debugging on Hermes.

For VSCode you should use the Debug iOS Hermes - Experimental launch configuration and not the Debug iOS launch configuration.

I did try both of those but it does not work for me. Following the link about debugging JS on Hermes using Google Chromes Devtools does not show the JS code to set breakpoints. I tried adding the folders to the Files tab in the tools but still nothing. As for the Debug iOS Hermes - Experimental launch config option here is what I get:

Screen Shot 2022-09-07 at 7 34 35 AM

rstor1 avatar Sep 07 '22 11:09 rstor1

Got the same error after I just created a new project. Setting :hermes_enabled => false resolves the problem. I disabled Flipper as well, not sure if that had any effect.

I tried setting hermes to false along with Flipper and still not working for me either. I get: Screen Shot 2022-09-07 at 7 34 35 AM

rstor1 avatar Sep 07 '22 11:09 rstor1

I can confirm that when creating an app with RN 0.69.0 it works as expected. CMD+D opens menu, click on Debug with Chrome opens up the debugger and there is no error in metro terminal. Screen Shot 2022-09-07 at 12 38 55 PM

For now, I suppose I will try to go back to RN 0.69.0.

rstor1 avatar Sep 07 '22 16:09 rstor1

The issue with findXcodeProject is due to the VS Code react-native plugin needing an update to fix the path. A temp solution can be found here https://github.com/microsoft/vscode-react-native/issues/1781#issuecomment-1195610125

cuongvoong avatar Sep 07 '22 17:09 cuongvoong

The issue with findXcodeProject is due to the VS Code react-native plugin needing an update to fix the path. A temp solution can be found here microsoft/vscode-react-native#1781 (comment)

Thanks, I did try that at one point but it did not work for me.

rstor1 avatar Sep 07 '22 17:09 rstor1

I think :hermes_enabled => true, making it false like :hermes_enabled => false, is working and i am able to debug with ios. but i want to know if i disable hermes then it can make any issue or problem in our development?

:hermes_enabled => true and debugger not working so if you want to debug ios you have to disable hermes.

otherwise, with :hermes_enabled => true using debugger i don't know how will work that.

Siliconvelly avatar Sep 09 '22 06:09 Siliconvelly

@Siliconvelly I have the same problem, i want to use hermes, but i can't debugger by phone

KokoTa avatar Sep 09 '22 06:09 KokoTa

experiencing the same issue. My project has flipper disabled fyi

maxmandia avatar Sep 09 '22 19:09 maxmandia

Try #34608

Bayramito avatar Sep 09 '22 19:09 Bayramito

Same issue on RN 0.70.0. Confirm that RN 0.69.0 works fine.

Frit avatar Sep 12 '22 16:09 Frit

Same issue on RN 0.70.0. Confirm that RN 0.69.0 works fine.

I just switched to expo...

maxmandia avatar Sep 12 '22 16:09 maxmandia

Same issue on RN 0.70.0. Confirm that RN 0.69.0 works fine.

I just switched to expo...

It appears I have no other choice :)

Frit avatar Sep 12 '22 17:09 Frit

Got the same error after I just created a new project. Setting :hermes_enabled => false resolves the problem. I disabled Flipper as well, not sure if that had any effect.

This works for me - thanks

MahmoudAziz1996 avatar Sep 12 '22 23:09 MahmoudAziz1996

A few things going on here:

  1. the error (and you can see it in the screenshot too) is because clicking on "open debugger" triggers a command to connect to the Flipper desktop app: info Opening flipper://null/Hermesdebuggerrn?device=React%20Native... Because you don't have Flipper running, it tries to open it and fails with error Browser exited with error:, Error: invalid url, missing http/https protocol
  2. this is related to the fact that Hermes is on by default starting from 0.70.
  3. as mentioned by @justin-tay, with Hermes you can not use the the "old way" of debugging via Chrome directly in browser.

All of that said:

  • for some reason on my machine cmd+D didn't open the debugging menu, nor did pressing "d" in Metro. This is something that needs to be fixed.
  • the overall debugging story for react-native at the moment is a bit weak, but we are trying to get a few engineers from our companies to focus on this a bit more to improve the situation.

For now, using Flipper as debugging tool is the solution you should go for.

kelset avatar Sep 13 '22 12:09 kelset

@kelset in the future is there a way to debug via Chrome?

HoaiHuynh avatar Sep 14 '22 04:09 HoaiHuynh

Hi, I can confirm that using: "react": "18.1.0", "react-native": "0.70.0", and :hermes_enabled => true, using for example google chrome to debug your code etc is not working, but white same configuration and hermes_enabled => false is working.

Maybe someone knows if there is a way to still use a browser to debug your app but with hermed_enabled => true?

Mihai-github avatar Sep 16 '22 14:09 Mihai-github

Hello everyone. I'm also waiting for a fix and looking for a solution. I suggest using this before debugging is fixed.

https://github.com/infinitered/reactotron

This is the best debugger replacement in my opinion.

zohayk avatar Sep 16 '22 14:09 zohayk

For me I have typed manually http://localhost:8081 then the debug console opened on chrome. #Hope This helps

jyotiprakash111 avatar Sep 19 '22 14:09 jyotiprakash111

it does works on changing Hermes engine in pod file to false

:hermes_enabled => true,

If not working after this run pod install and build you project again. This worked for me

Azaz0723 avatar Sep 21 '22 07:09 Azaz0723

@HoaiHuynh there is currently a bug preventing the loading of source maps in that case. We are currently working on a fix.

In the meantime, the primary way to debug JavaScript running in Hermes is via Flipper.

mattbfb avatar Sep 21 '22 20:09 mattbfb

Flipper doesn't work well either

skurgansky-sugarcrm avatar Sep 29 '22 11:09 skurgansky-sugarcrm

@skurgansky-sugarcrm can you share more details about your environment, the steps you've attempted, and any errors you receive?

Launching a new app via npx react-native init DebugProject && cd "./DebugProject" && npx react-native run-android and then opening the "Hermes Debugger (RN)" in Flipper should still work in RN 0.70 (e.g. you can press the pause button, then scroll the app to trigger a break. confirmed locally). Does this fail for you?

mattbfb avatar Sep 29 '22 12:09 mattbfb

@mattbfb i have node 18 if it matters npx react-native init DebugProject && cd "./DebugProject" && npx react-native run-ios Flipper is of latest version just running template project on ios i go Cmd+D > Open Debugger > console logs

info Opening flipper://null/Hermesdebuggerrn?device=React%20Native...
error Browser exited with error:, Error: invalid url, missing http/https protocol

then i try to open Flipper manually because it's not started via upper steps image

  1. File system panel is empty though Cmd+O can see project files
  2. Breakpoints do not work at all (debugger statement helps a little here)

skurgansky-sugarcrm avatar Sep 29 '22 13:09 skurgansky-sugarcrm

@skurgansky-sugarcrm Thanks for sharing those details.

The filesystem view is currently not populated by the Hermes debugger, but you can find an "Open file" menu item in the collapsed items under the vertical "..." to the right of the "Filesystem" and "Snippets" tab in your screenshot.

e.g. in the DebugProject that you created above, if you add some code to App.js and then open that file in the "Hermes Debugger (RN)", you should be able to set and reach a breakpoint e.g.: Screen Shot 2022-09-29 at 3 46 46 PM

mattbfb avatar Sep 29 '22 20:09 mattbfb

@mattbfb i should be able to set breakpoint but i just can't. =(

debugger in Flipper (Version 0.166.0 (50.0.0), RN 0.70.1) just does not want to:

  1. pause where i clicked to create a breakpoint like if source maps were not correct
  2. remove them when i try (Remove breakpoint or Remove all breakpoints )

skurgansky-sugarcrm avatar Sep 30 '22 07:09 skurgansky-sugarcrm