Skip to content

Flavors documentation omits important section for appFlavor when building from XCode #11178

@navaronbracke

Description

@navaronbracke

Page URL

https://docs.flutter.dev/deployment/flavors

Page source

No response

Describe the problem

The flavors documentation does not include a step to set the FLUTTER_APP_FLAVOR Dart define for the appFlavor constant. This is important to include when building from XCode, as otherwise the appFlavor is null.

Expected fix

When setting up Schemes in XCode, we should also add the following to the documentation:

  1. Navigate to the Build Settings of the target(s)
  2. If DART_DEFINES does not exist yet
    2a) Click the + button in the top left
    2b) Click Add User-Defined Setting
    2c) For the name enter DART_DEFINES
    2d) For the value take the base64 encoded version of FLUTTER_APP_FLAVOR=<value>, where <value> is the name of the flavor that is expected to be the appFlavor in Dart
  3. If DART_DEFINES does exist, the values are delimited by a comma (this should be verified, I am not sure) But it is important to encode the entire string as base64
  4. If DART_DEFINES is already defined in Generated.xcconfig, delete the Generated.xcconfig and enter the Dart defines in XCode, before trying again.

Additional context

I confirmed that this is not a tool bug, as the Flutter tool already picks up existing DART_DEFINES from the iOS/MacOS Scheme when present.

Screenshot 2024-09-25 at 14 30 16

I would like to fix this problem.

  • I will try and fix this problem on docs.flutter.dev.

Metadata

Metadata

Assignees

No one assigned

    Labels

    e2-daysEffort: < 5 daysfrom.page-issueReported in a reader-filed concernp2-mediumNecessary but not urgent concern. Resolve when possible.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions