我进行了搜索,但除了 Visual Studio Code 文档外我找不到任何外部资源,并且仅遵循这些文档不允许在 iOS 或 Android 中调试 React Native 应用。
我不断收到错误消息(这个错误消息适用于 Android,适用于 iOS 也是类似的:
[vscode-react-native] [Warning] Couldn't import script at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false. Debugging won't work: Try reloading the JS from inside the app, or Reconnect the VS Code debugger: path must be a string
我的 launch.json
文件为:
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Android",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "android",
"internalDebuggerPort": 9090,
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug iOS",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "ios",
"target": "iPhone 6s",
"internalDebuggerPort": 9090,
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Attach to packager",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "attach",
"internalDebuggerPort": 9090,
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
},
{
"name": "Debug in Exponent",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "exponent",
"internalDebuggerPort": 9090,
"sourceMaps": true,
"outDir": "${workspaceRoot}/.vscode/.react"
}
]
}
我正在尝试在 iOS 模拟器或 Android 设备中进行调试,但该过程从未附加到外部 JS 调试器。
最佳答案
进入vscode调试选项,选择调试类型
- 选择附加到打包器
通过
运行您的 React native 应用程序react-native run-android
-> 摇晃手机并选择 Debugg remote JS 选项
完成...
关于android - 如何在 Visual Studio Code 中为 React Native 设置调试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41315773/