Support for app flavors in flutter tooling (retake)#11734
Merged
mravn-google merged 8 commits intoflutter:masterfrom Aug 23, 2017
Merged
Support for app flavors in flutter tooling (retake)#11734mravn-google merged 8 commits intoflutter:masterfrom
mravn-google merged 8 commits intoflutter:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Retake of #11676, with fixes to make cocoon tests run.
Fixes #11547.
flutter build,flutter run, andflutter drivenow understand app "flavors" or "variants". This means that you can build different flavors of your app from the same source code, but with different configuration as defined by platform-specific build settings. Flavors are orthogonal to the existingdebug/profile/releasebuild modes:Flavors at the Flutter CLI level map to product flavors in Android projects (with Flutter build modes mapping to Android build types) and to schemes in iOS projects (with Flutter build mode/flavor pairs mapping to Xcode build configurations).
The Android Gradle build tasks corresponding to the above would be
Android makes the flavor available to Java code as
BuildConfig.FLAVOR. It can be communicated to the Dart side using platform channels (a convenient plugin for handling this could be built).For Xcode, one can define build configurations according to a custom naming scheme, e.g.
---and then map each build configuration to one of two custom schemes named
FreeandPaid. Each build configuration might include a user-defined Build Setting entry, such asFLAVORwith valuesfreeorpaid. This value can be exposed to ObjC by adding aFlavor: $(FLAVOR)key/value pair to Info.plist and then accessed using[[NSBundle mainBundle].infoDictionary valueForKey:@"Flavor"]. Flutter tooling does not care about how you set this up, it merely builds the Xcode project specifying the relevant build configuration and scheme.A sample project using this setup is included for integration testing in
dev/integration_tests/flavors. More documentation will be provided in a separate PR.