How to set --dart-define in Xcode

I'm not able to build and launch the app from xcode alone. Meaning pressing the button "Start the active scheme".

I've tried setting the User-Defined setting DART_DEFINES under Build Settings for the different schemes accordingly. E.g.:

  Debug-at     ENV=at
  Debug-dev    ENV=dev

and so on. Picture for clarity:

enter image description here

When trying this, the build fails with the following error:

error build: Command PhaseScriptExecution failed with a nonzero exit code

Am I missing something obvious? Are there other ways of passing command line arguments when building/launching from xcode?

Launching the application on an IOS simulator from VSCode using the following (in launch.json) works fine:

    "name": "[dev] myAppName",
    "request": "launch",
    "type": "dart",
    "args": [
        "--dart-define", "ENV=dev",
        "--flavor", "dev"

Running the following command works fine:

flutter build ipa --flavor dev --dart-define "ENV=dev"


  • Okey, so I've finally solved it... To set values corresponding to what is entered using the CLI operator --dart-define, and use that when running from XCode it is correct to use the User-Defined variable called DART_DEFINES. What is not obvious is that the value that should be entered there is your value base64 encoded. So in my case, if I use the following from VSCode or CLI:

    --dart-define "ENV=at"

    Then the value of DART_DEFINES in XCode should be RU5WPWF0

    When running/building from VSCode or using the CLI to build/run, flutter tools will base64 encode the value and set the value in the runners project file (typically project.pbxproj in Runner.xcodeproj) and the generated files located in the ios/Flutter directory. The files are currently named and Generated.xcconfig. Those files are used when running/building from XCode.