Skip to content

Flavor API should be derived at the flutter assemble level so it is set correctly when run from native tooling, like Android Studio or Xcode #155951

@jmagman

Description

@jmagman

Currently, the app flavor is passed into the FLUTTER_APP_FLAVOR based on the --flavor flag passed into the Flutter tool, as implemented in #134179

final String? cliFlavor = argParser.options.containsKey('flavor') ? stringArg('flavor') : null;
final String? flavor = cliFlavor ?? defaultFlavor;
if (flavor != null) {
if (globals.platform.environment['FLUTTER_APP_FLAVOR'] != null) {
throwToolExit('FLUTTER_APP_FLAVOR is used by the framework and cannot be set in the environment.');
}
if (dartDefines.any((String define) => define.startsWith('FLUTTER_APP_FLAVOR'))) {
throwToolExit('FLUTTER_APP_FLAVOR is used by the framework and cannot be '
'set using --${FlutterOptions.kDartDefinesOption} or --${FlutterOptions.kDartDefineFromFileOption}');
}
dartDefines.add('FLUTTER_APP_FLAVOR=$flavor');
}

However, that solution doesn't work when run from native tooling, like Android Studio of Xcode, which calls only into flutter assemble, so FLUTTER_APP_FLAVOR is unset.

The proposed community solution at flutter/website#11178 for iOS/macOS requires DART_DEFINES to be individually set per Xcode scheme/config, which would be very easy to get out-of-sync, and essentially unnecessary given that assemble already has all the information it needs to parse which flavor should be used.

It would be better if the flavor parsing logic were pushed down into assemble.

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listplatform-iosiOS applications specificallyplatform-macBuilding on or for macOS specificallyteam-toolOwned by Flutter Tool teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-toolTriaged by Flutter Tool team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions