I am trying to build and run a project in both iOS and Web from VS Code. Is there any way to do this?
I have tried running flutter run -d all but that only runs iOS, even though flutter devices lists both of them
Yep, you can create a compound launch config in your .vscode/launch.json. This one creates three configs, one to launch on the current device (shown in the status bar), one to launch on iOS, and one to launch on Android. It then creates a compound config that will launch on iOS and Android devices at the same time. You can change one of the device IDs to chrome to launch on Chrome.
{
"version": "0.2.0",
"configurations": [
{
"name": "Current Device",
"request": "launch",
"type": "dart"
},
{
"name": "Android",
"request": "launch",
"type": "dart",
"deviceId": "android"
},
{
"name": "iPhone",
"request": "launch",
"type": "dart",
"deviceId": "iphone"
},
],
"compounds": [
{
"name": "All Devices",
"configurations": ["Android", "iPhone"],
}
]
}
More info can be found on the Flutter wiki.
Related
I installed Flutter and I have a project that used it (Flutter Web).
As IDE I use VsCode.
When I run the app using command line (flutter run --no-sound-null-safety) it works well, instead when I use VsCode I get this error:
ChromeProxyService: Failed to evaluate expression 'Future': InternalError: No frame with index 17.
ChromeProxyService: Failed to evaluate expression 'that': InternalError: No frame with index 17.
...
I launch the app with fn+f5 and I created this .vscode/launch.json file:
{
"version": "0.2.0",
"configurations": [
{
"name": "Web nosound null",
"type": "dart",
"request": "launch",
"deviceId": "chrome",
"args": [
"--no-sound-null-safety"
]
},
{
"name": "Web sound null",
"type": "dart",
"request": "launch",
"deviceId": "chrome",
"args": []
},
]
}
I tried also flutter clean but nothing changes, also uninstall and reinstall Flutter seems not to solve the problem.
VsCode is updated.
What am I wrong?
I am having trouble launching a web project in Google Chrome incognito mode. I have tried making changes to the launch.json file but it's not working.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"runtimeArgs": [ "--incognito"],
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
There are two types of configurations in vscode debugging,
Launch via NPM and Launch via npm
I tried but didn't find the docs anywhere
What's the difference between those?
// #launch via NPM
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"debug"
],
"port": 9229,
"skipFiles": [
"<node_internals>/**"
]
},
// #launch via npm
{
"name": "Launch via NPM",
"request": "launch",
"runtimeArgs": [
"run-script",
"debug"
],
"runtimeExecutable": "npm",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
}
I get an answer from vscode dev: https://github.com/microsoft/vscode/issues/127232
There is no real difference: the launch config with the "port" attribute is contributed by the legacy node.js debugger and will disappear soon. The second launch config is more recent and comes from js-debug.
Since the legacy debug configurations are automatically redirected to js-debug and since port 9229 is the default debug port anyway, there should be no differences.
Windows 10 x64 Professional
Visual Studio Code v1.26.1
Debugger for Chrome 4.9.0
I have the simple config (launch.json):
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080/index.html",
"webRoot": "${workspaceFolder}"
}
]
}
The launch.json file is located in the .vscode subdirectory of my project folder. Also my folder contains the index.html file.
I open my project folder in Visual Studio Code and press F5 key, but I get the ERR_CONNECTION_REFUSED error in the new Google Chrome instance. I.e. the browser can't to open my index.html page.
But this variant works fine:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against index.html",
"file": "${workspaceFolder}/index.html"
}
]
}
Why I have the problem with the localhost variant and how can I solve it?
I had the same problem this week. As far as I understand the first launch config (using URL and webroot) needs a local (f.i. node.js) web server up and running.
The second launch config "just" runs the local file(s).
Are there any step by step instructions for beginners to be able to see the output of VSCode code runs in Chrome Developer Tools?
Here is what I have done:
Installed "Debugger for Chrome" 3.1.7 extension with VSCode - extension installed OK, along with Live Server 1.6.7. Launch.json file shows up as below. However, even if I restart Chrome and VSCode, I can't see any logs in Chrome Developer tools.
Thanks!
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceRoot}"
},
{
"type": "chrome",
"request": "attach",
"name": "Attach to Chrome",
"port": 9222,
"webRoot": "${workspaceRoot}"
}
]
}