我在 Visual Studio 代码中打开了一个 React Native 项目,我尝试在物理连接的 iOS 设备上运行该项目。我直接从 Xcode 成功地在设备上运行了该应用程序,但是从 Visual Studio Code 中我遇到了问题。我相信我需要将设备的配置添加到 launch.json 中。我在那里尝试了不同的条目,但似乎不起作用。为连接的 iOS 设备添加配置的正确方法是什么?
最佳答案
如果您需要针对特定设备,可以这样做:
{
"name": "iOS Device",
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
"type": "reactnative",
"request": "launch",
"platform": "ios",
"sourceMaps": true,
"target": "device",
"outDir": "${workspaceRoot}/.vscode/.react",
"runArguments": [
"--device",
"DEVICE NAME"
],
}
所以你需要设置
"target": "device"
告诉调试器在设备上运行,然后通过 "runArguments"
设置设备名称.
关于ios - 在 VS Code : add configuration for iOS Device to launch. json 中 react native ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44877653/