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?
Running your app on Android devices 1 Enable Debugging over USB Most Android devices can only install and run apps downloaded from Google Play, by default. ... 2 Plug in your device via USB Let's now set up an Android device to run our React Native projects. ... 3 Run your app
Visual Studio. ReactNative is a great way to build native, cross platform app for iOS and Android using JavaScript. We recently announced the launch of a Visual Studio Code Extension that enables you to build, debug and preview Apache Cordova apps. And today we’re pleased to announce the availability a similar extension for ReactNative!
ReactNative apps are also written with JavaScript – or, more specifically, they are written with the React/JSX framework. But, rather than run in a Webview like Cordova, code runs in a JavaScript engine that’s bundled with the app. ReactNative then invokes native UI components (e.g. UITabBar on iOS and Drawer on Android) via JavaScript.
It’s under 50MB, completely free, and runs on Mac OS X, Linux, and Windows. On a decent network connection you’ll have it installed in under 2 minutes! Then visit the Visual Studio Code Marketplace to get the ReactNative extension. You can also install it directly from within the editor.
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"
.
Try with react-native run-ios --device "your device name"
Device name you can find in xcode
You can add this in package.json
also
{
start:ios: "node node_modules/react-native/local-cli/cli.js run-ios --device \"your device name\""
}
You may need to install ios-deploy
npm install -g ios-deploy
For vscode launch.json
you can add these configuration node node_modules/react-native/local-cli/cli.js run-ios --device \"your device name\"
in launch.json
too
{
"type": "node",
"request": "launch",
"name": "Run app",
"program": "${workspaceRoot}/node_modules/react-native/local-cli/cli.js",
"cwd": "${workspaceRoot}",
"runtimeArgs": [
"run-ios",
"--device",
"\"your device name\""
],
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With