React Native in VS Code: add configuration for iOS Device to launch.json

Viewed 6601

I have a React Native project open in Visual Studio code, and Im trying to run the project on a physical connected iOS device. I successfully ran the app on the device directly from Xcode, but from Visual Studio Code I'm having issues. I believe I need to add a configuration for the device into launch.json. I have tried different entries in there but non seem to work. What is the proper way to add a configuration for a connected iOS device?

3 Answers

If you need to target a specific device, this is how it´s done:

{
  "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"
  ],
}

So you need to set "target": "device" to tell the debugger to run on a device, and then you set the device name through "runArguments".

Related