You can take a look at the exact diff here in commit cef5fbff. You may copy it to the configuration file that opens when you click the cog wheel on debug pad in VS Code. Below you may find a sample I use in my apps. In order to run the app with desired flavor in VS Code you can define your own launch.json configuration. we skip codesign for iOS (we’ll sign our app with fastlane).we define build numbers ( 1) and build names ( 1.0.0).IOS: flutter build ios -release -no-codesign -t lib/main_tst.dart -build-name=1.0.0 -build-number=1 -flavor tst Ordinary apk: flutter build apk -release -t lib/main_tst.dart -build-name=1.0.0 -build-number=1 -flavor tstĪpp bundle: flutter build appbundle -target-platform android-arm,android-arm64 -release -t lib/main_tst.dart -build-name=1.0.0 -build-number=1 -flavor tst Typically you would run following commands to build flavored app: This step of the configuration you can investigate in commit a4c7ef8e. Void mainCommon ( AppConfig config ) => runApp ( MyApp ( config )) In each of them you can define respective configuration and later just start execution of the app from a common function. The easiest way is to rename main.dart to main_common.dart and create: In order to take the advantage of flavors in Flutter app you should define 3 separate main files 1 that will handle all the configuration details different for each scheme. You will benefit from Swift later in your project when you’ll have to write some platform specific code. AndroidX is a future of Android development so while starting new project you should definitely have it enabled. It’s a good practice to create new projects with Kotlin and Swift support. In this article I use Flutter v1.7.8+hotfix.3 and demo app is created with Kotlin, AndroidX, and Swift support by: There is no native support of Flutter apps in fastlane but we can define fastlane configuration for Android and iOS projects and treat them as typical native apps. This gives us a very convenient and reproducible way of distributing our app. Fastlane allows to automate provisioning and signing of iOS apps as well as screenshot capture or updating the description in store. Those can be reproduced both on developer’s computer, but also on CI/CD platform. A set of files can describe signing, build and deployment phases. In this article I will show how to use flavors with fastlane but in general you can handle flavors manually or in typical CI environment like Codemagic or Bitrise.įastlane allows you to define specific lanes for each app in code like deploy_to_appcenter or deploy_to_store. In my daily job I use fastlane to automate apps deployment to QA and app stores. Especially on iOS there are multiple ways to provide different bundle ids or configuration parameters. There are multiple ways to achieve this and with each new project you’ll have a chance to improve your approach. All it takes to define flavors is to add and edit few files. It’s been battle tested with several apps already and is getting better with each new project.įor instance our test builds have AppCenter distribution packages to automate updates and additional logging included, dev builds have very verbose logging, and production apps come without unnecessary diagnostics but with production logging configuration.įlutter comes with built-in flavor support but default project is not prepared to handle them. ![]() Presented way works really well for me and my colleagues. ![]() In this article I’ll show a similar but a subtly different approach and focus mostly on iOS part. Flutter Ready to Go (flavors, connectivity and more) by Julio Henrique Bitencourt.Flavoring Flutter by Salvatore Giordano,.Creating flavors of a Flutter app (Flutter & Android setup) by Natalie Masse Hooper,.There are several great articles on build flavors just to mention: In commercial projects it’s a standard way of distributing apps. By incorporating flavors in your project you can build your app with different configuration options, styles or feature sets. The concept of flavors is taken from Android apps and can be applied to iOS in various ways (more on this later). TL DR Just go to the repository where all the flavors are already configured. In this tutorial you will learn how to prepare ordinary Flutter project to have 3 different flavors ( dev, test and production) and how to handle build, signing and deployment with fastlane. ![]() If you’re looking for a good support of flavors in Flutter apps, check out the very_good_cli. Since then many things have changed in Flutter. ![]() Note: This article was written in July 2019. In case of mobile apps a good way to have separate configurations is usage of flavors. It’s a good practice to build separate apps for development, test and production environment. Flavors in Flutter with Fastlane - yet another guide
0 Comments
Leave a Reply. |