12

I'm trying to run the debug mode on visual studio code (click "run and debug") for my flutter app, but when I do I'm facing the following issue:

The Xcode project defines schemes: release, private.

Exception: You must specify a --flavor option to select one of the available schemes.

So I have these two "flavours" but I'm not sure how to specify which to use. Normally, running the app through the terminal would require me to specify it as such: flutter run --flavor private but I'm not sure how to do the same for debug. Is there an equivalent command for debug mode?

Would appreciate some help, thanks in advance!

7 Answers 7

7

This answer will only be what you're looking for if you created your flavors (and schemas) correctly (check this for reference: Flavors in Flutter by Flutter Explained channel) and if you are using android studio, since it is there were I solved it.

After having followed the video or any other correct explanation or set of steps, it is true that you cannot run the debugger nor have any of the DevTools attached if you run your app through a command. For example in my case, one of my flavors is named 'staging' so the command I ran would be:

flutter run --flavor staging -t lib/main_staging.dart

But by doing so, yes, you can run your app, but you won't see any of the previously mentioned tools attached. What I did (and this is the answer) is this:

enter image description here

and then added the additional args (in my case I wanted to run the 'staging' flavor or schema, as you already may have noticed) so:

enter image description here

After that, I got rid of this exception

Exception: You must specify a --flavor option to select one of the available schemes.

That is: the exception did not show again when hitting either one of these two buttons ('Run' or 'Debug'):

enter image description here

And that would be it. After that, I was able to see the debugger working as well as the DevTools.

Sign up to request clarification or add additional context in comments.

Comments

6

you have to add

"args":[ "-- flavor", "flavor_name" ]

in your .vscode > launch.json to obtain something like this:

 "configurations": [
        {
            "name": "flutterApp",
            "request": "launch",
            "type": "dart",
            "args": [
                "--flavor",
                "dev",
            ]
        },

then you need to launch the debugger from here selecting the correct configuration: enter image description here otherwise it will not work

Comments

5

In your launch.json file configurations, you can use this format for your iOS app to run:

  {
            "name": "production",
            "request": "launch",
            "type": "dart",
            "args": [
                "-t",
                "lib/main_prod.dart",
                "--flavor",
                "prod"
            ]
        }

Comments

1

I encountered this, and had multiple schemes. In order to resolve it in addition to adding:

--flavor {scheme name}

to my run command, I also had to create a duplicate build configuration named

Debug-{scheme name}

You can do this by navigating to your project Runner in xCode, then Editor->Add Configuration-> Duplicate Debug (or your desired build),

then name in the format {Configuration}-{scheme name} Build Config Image

Comments

0

yes , you have to add arguments in launch.json file configurations

"args":[ "-- flavor", "flavor_name" ]

N.B: you will get this json file in .vscode folder of your project

2 Comments

I have added it, but it still gives me the same error.
same her . after adding result remain same.
0

Open your launch.json, create two different objects with different names like below:

"configurations": [
 {
   "name": "my-app sandbox",
   "request": "launch",
   "type": "dart",
   "args": ["--flavor", "sandbox"]
 },
 {
   "name": "my-app production",
   "request": "launch",
   "type": "dart",
   "args": ["--flavor", "production"]
},
]

And while running in debugger select the my-app production / my-app sandbox name, it will run without any issue.

Comments

-1

In Xcode I had to create the missing scheme and go to Manage Schemes and mark as shared.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.