iOS / macOS Flavors
This guide will walk you through how to set up an app in which there are 2
flavors: internal and stable. It will cover how to validate a patch on the
internal flavor and then promote the patch to the stable flavor on iOS.
This guide was originally written for iOS, but the same steps can be applied to macOS.
Prerequisites
Section titled “Prerequisites”This guide assumes the Shorebird command-line is installed on your machine and that you are logged into an account. Refer to the getting started instructions for more information.
Create a project
Section titled “Create a project”Create a new project using shorebird create flavors.
Configure flavors
Section titled “Configure flavors”Next, edit the iOS project to support two flavors: internal and stable by
following the instructions in the
Flutter documentation.
Re-initialize Shorebird
Section titled “Re-initialize Shorebird”Next, re-initialize Shorebird in the current project via
shorebird init --force.
The re-generated shorebird.yaml should look something like:
Since the project contains flavors, shorebird init generates an app per
flavor.
Create a release
Section titled “Create a release”Now that the apps have been created on Shorebird, releases need to be created
(one for each flavor), using the shorebird release ios command.
Verify the releases were created successfully by visiting the Shorebird console.
Preview the release
Section titled “Preview the release”Next, preview the app release locally on a device or emulator, use
shorebird preview.
This will download the releases and run them on your device.
In addition to previewing the releases locally, you should also submit the generated IPAs to the App Store. In this case, both apps can be part of the internal test flavor and only the stable variant should be promoted to production.
Creating a patch
Section titled “Creating a patch”Now that the internal and stable releases are on the App Store, a patch can be
created using shorebird patch ios. For the sake of this example, adjust the
app theme to use deepOrange as the seed color in lib/main.dart:
Now that the changes have been applied, patch the internal variant:
Validate the patch by visiting the Shorebird console then select the internal release or re-launching the internal release.
The first time the app is re-launched, the purple theme should still be visible, and Shorebird will detect and install the patch in the background. Kill and re-launch the app a second time to see the applied patch.
If all went well, you should see the patch was applied after re-launching the app a second time. All devices that have the internal variant of the app installed should also receive the patch 🎉
Promote the patch
Section titled “Promote the patch”Once you have validated the patch internally, you can promote the patch to the stable variant via:
At this point, you have a setup which allows you to push patches to internal testers before promoting them to production 🎉
The full source code for this example can be found here.
Adding new flavors
Section titled “Adding new flavors”If you want to add a new flavor to your project after initializing Shorebird, you can do so by following the same steps as before.
Edit the iOS project to add a third flavor, beta, by following the
instructions in the
Flutter documentation.
Add this to your shorebird.yaml by running shorebird init:
The resulting shorebird yaml: