Home > Mobile >  Unable to use VSCode's launch.js custom configuration to run my flutter app with custom Xcode s
Unable to use VSCode's launch.js custom configuration to run my flutter app with custom Xcode s

Time:10-04

I made a custom Xcode Target and Scheme for my flutter app in order to run a development version of the app. I was able to successfully run the app (on a iOS Simulator) with the custom Xcode scheme using flutter run myApp --flavor myApp-dev

However, it's hard to debug when running in the command line, so I wanted to use VSCode to run it.

To do this, I added a new configuration in launch.js:

{
    // 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": [
        {
            "name": "myApp",
            "program": "lib/main.dart",
            "request": "launch",
            "type": "dart"
        },
        {
            "name": "myApp-dev",
            "program": "lib/main.dart",
            "request": "launch",
            "type": "dart",
            "args": ["--flavor myApp-dev"]
        }
    ]
}

The --flavor option was added with the args attribute, and it does seem to run flutter run myApp --flavor myApp-dev when I click "Start Debugging" with the new configuration in VSCode, because providing an incorrect option (e.g. "-flavor") raises an error.

However, my app still seems to run without the custom Xcode scheme I made. I can't figure out if this is the right way to do it, or what causing the "args" attribute to not seem to work as I expected it to.

CodePudding user response:

Figured out eventually that all the arguments that are separated by spaces in the command line have to be separated by commas. So the fix is:

{
    "name": "myApp-dev",
    "program": "lib/main.dart",
    "request": "launch",
    "type": "dart",
    "args": ["--flavor", "myApp-dev"]
}

Not sure why there is no documentation for this (or maybe I'm just too dumb to find it)... The closest thing to a documentation was this reference which didn't specify how to format the arguments.

  • Related