microsoft / vscode-react-native

VSCode extension for React Native - supports debugging and editor integration
https://marketplace.visualstudio.com/items?itemName=vsmobile.vscode-react-native
Other
2.62k stars 263 forks source link

React native cannot be debugged in a subdirectory #1081

Closed i7soft closed 4 years ago

i7soft commented 5 years ago

Folder structure

├ project ----├ .vscode --------├ launch.json --------├ settings.json ----├ platform --------├ mobileReactNative ☜ react native root ------------├ index.js

settings.json has set the react-native-toos.projectRoot like this:


{
    "react-native-tools":{
        "projectRoot":"./platform/mobileReactNative"
    },
    "react-native-tools.projectRoot": "./platform/mobileReactNative"
}

./platform/mobileReactNative/index.js :


var ReactNative=require('react-native');

console.log('hello bobo');

var AppRegistry=ReactNative.AppRegistry;

import Loader from './Loader';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, ()=>Loader);

Actual Behavior

  1. Cannot enter breakpoints during debugging

Expected Behavior

Software versions

Outputs (Include if relevant)

<img width="1112" alt="WeChat7d83c244d24614f1ca9c521c087605b8" src="https://user-images.githubusercontent.com/10511797/63495494-90ae9100-c4f2-11e9-871b-9c8acaf8ebf8.png">

- Output of the React-Native output channel (View -> Toggle Output -> Select React-Native in ListBox):

info Starting custom debugger by executing:, echo A debugger is not needed: "/Users/shiqiren/MC/NewBest/project/platform/mobileReactNative" BUNDLE [ios, dev] ./index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (1/1), done.

BUNDLE [ios, dev] ./index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (1/1), done.

MAP [ios, dev] ./index.js ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ 100.0% (1/1), done.

- Output of the Developer Tools console (Help -> Toggle Developer Tools -> Select Console tab):

nothing

ruslan-bikkinin commented 5 years ago

Hi @i7soft and thanks for reporting. Please try the following steps and let us know if it helps:

SounD120 commented 5 years ago

Hi @i7soft . Do you have a chance to look at this?

i7soft commented 5 years ago

@ruslan-bikkinin @SounD120 thank you for the help. I have upgraded to 0.11.0, but when I debug ios, I canot enter the breakpoint too. I can only see the debug information with "console.log". In andorid, the debug information with "console.log" is only displayed in LogCat.

SounD120 commented 5 years ago

@i7soft Have you tried to put breakpoints in other files except index.js? Does debugging work there?

i7soft commented 5 years ago

@SounD120 In ios, still can't debug, in index.js too, but I found that I can hit other breakpoints (the code for these breakpoints is executed after the app has run for a few minutes)

SounD120 commented 5 years ago

Hi @i7soft . Could you please share a demo application and indicate where you set breakpoints that don't work?

i7soft commented 5 years ago

@SounD120 Ok, I will provide a demo and then record a video.

i7soft commented 5 years ago

@SounD120 demo and the video are in :

https://github.com/i7soft/reactNativeDemo

SounD120 commented 5 years ago

Hi @i7soft . Could you please try to add debugger; string at the top of your app.js file and let us know how it works for you?

i7soft commented 4 years ago

@SounD120 After add debugger; string at the top of app.js file, it can enter breakpoints in iOS,but still not work in Android

SounD120 commented 4 years ago

Hi @i7soft . I investigated the issue and proposed a fix for that. Could you please try it and let us know how it works for you? To do that please do the following:

i7soft commented 4 years ago

Hi @i7soft . I investigated the issue and proposed a fix for that. Could you please try it and let us know how it works for you? To do that please do the following:

  • Download and unzip compiled extension VSIX from fix-breakpoints-issue branch: vscode-react-native-0.11.1.vsix.zip
  • Uninstall extension
  • Close VS Code
  • Open VS Code
  • Click Extensions -> ... -> Install from VSIX... and select downloaded VSIX

i try this. ios can enter breakpoints,in android still not work

SounD120 commented 4 years ago

Hi @i7soft . As seen from your video in https://github.com/i7soft/reactNativeDemo repository, it looks like Remote JS Debug is disabled on Android emulator. Could you please try to enable it and let us know how debugging works with new extension version? To do that please do the following:

  1. Start Debug Android debug scenario and wait when application is built
  2. Run adb shell input keyevent 82 command in terminal to open React Native developer menu inside the app
  3. Enable Remote JS Debug
i7soft commented 4 years ago

@SounD120 thanks,it is work!!!!!!!!!! add debugger; string at the top of app.js file is need

SounD120 commented 4 years ago

@i7soft Have you tried new extension version with a fix https://github.com/microsoft/vscode-react-native/issues/1081#issuecomment-533490551 ? It should work without debugger; string at the top of App.js file. Could you please try it and let us know how it works for you?

i7soft commented 4 years ago

0.11.1is work without debugger;string @SounD120 🎉🎉🎉🎉🎉

SounD120 commented 4 years ago

@i7soft Glad to hear it. This fix will be released as a part of new extension version. We'll let you know when it comes out.

i7soft commented 4 years ago

@SounD120 Thank you for your work~👍

SounD120 commented 4 years ago

Hi @i7soft. React Native Tools v0.12.0 with a fix for that has been released.