I’m presently engaged on a Flutter mission the place I’ve six flavors for 2 variants: Free and Professional. Every taste corresponds to totally different environments like dev, uat, and prod.
Initially, I had separate fundamental.dart recordsdata for every taste, resembling:
- main_free_dev.dart
- main_free_uat.dart
- main_free_prod.dart
- main_pro_dev.dart
- main_pro_uat.dart
- main_pro_prod.dart
Nevertheless, I realized about utilizing the –flavor choice in Flutter to streamline this course of and handle the whole lot with a single fundamental.dart file.
Utilizing the –flavor flag, I move the flavour identify from the command line. For instance:
flutter run --flavor freeDev
On this setup, I deal with flavor-based useful resource assignments and different flavor-specific logic inside the principle.dart file by checking the appFlavor variable, which will get the flavour identify handed by means of the command.
This method works completely for working the appliance on each Android and iOS.
Downside:
Whereas I can construct APKs utilizing the GUI in Android Studio, I face points when making an attempt to construct an IPA for iOS. Particularly:
- I can’t move the flavour identify as an additional argument when archiving the construct by means of Xcode.
- I attempted including the flavour to the Xcode scheme, however the app all the time receives null for the appFlavor worth when archiving.
This prevents me from producing a flavor-specific IPA.
What I’ve Tried:
- Configuring the flavour within the Xcode scheme.
- Operating the archive utilizing the Xcode GUI.
Each approaches outcome within the appFlavor being null in the course of the construct course of.
Query:
- How can I move the flavour identify accurately when archiving an iOS construct utilizing Xcode in order that my app can deal with flavor-specific logic with a single fundamental.dart file?
- Is there a correct option to configure flavors for iOS builds in Xcode to make this work seamlessly?