This is a template and application delivery platform for the upcoming BirdCorner Apps.
Released into the public domain under The Unlicense.
This template takes a new Flutter application from an empty repository to a signed build in Apple TestFlight and a draft release on the Google Play internal track in roughly 30–60 minutes, most of which is waiting for remote builds and API calls.
Done by hand, the same work is a one- to two-day checklist spread across Google Cloud, Firebase, the Apple Developer Portal, App Store Connect, Play Console, Codemagic, OneSignal, Sentry and Shorebird — with plenty of places to mistype a bundle ID and only find out three consoles later.
Everything below is driven by setup.sh, which is idempotent enough to be re-run
after a failure, and by setup-rollback.sh, which tears the created resources
back down when you want to start over.
The project ships with dev, stg and prod flavors. The setup script derives all names and
identifiers from your repository name and domain, then propagates them through Dart, Gradle, Xcode,
Fastlane and CI configuration. Most integrations are provisioned per flavor — separate bundle IDs,
separate cloud projects, separate crash-reporting projects, separate push apps — while the CI
application, the Shorebird app and the repository itself are shared across all three:
- Google Cloud + Firebase — creates one project per flavor, links billing, enables the Firebase, Test Lab and Tool Results APIs, creates a Test Lab results bucket, assigns IAM roles, and creates scoped service accounts with downloaded keys.
- Firebase configuration — runs
flutterfire configurefor each flavor and commits the generatedfirebase_options_*.dartfiles (on Linux this is delegated to a Codemagic workflow, since the iOS side of the configuration needs macOS). - Apple Developer Portal / App Store Connect — creates the app record, registers bundle IDs, enables Push Notifications and App Groups capabilities, creates and associates the OneSignal notification-service-extension bundle ID and app group, and submits the initial app privacy details.
- Google Play — builds the first app bundle and walks you through the one manual step Google
still requires (creating the app entry and uploading the initial
.aab). - OneSignal — creates one OneSignal app per flavor, creates a dedicated FCM service account, and uploads the Android FCM credentials and the iOS APNs certificate to OneSignal automatically.
- Sentry — creates a project per flavor via the API, retrieves or provisions a DSN with a sane rate limit, and wires the DSN into both build-time and runtime env files.
- Shorebird — initialises the app for over-the-air patching (one Shorebird app, flavor-aware), so production fixes can ship without another store review.
- Codemagic — registers the repository as a Codemagic application, installs the CI/CD deploy key, and uploads ~25 secrets (App Store Connect API key, signing key, Play Console service account JSON, per-flavor Firebase service accounts, Sentry and Shorebird tokens, and your developer contact details) so CI is green on the first run.
Finally it commits the whole generated setup, pushes it, and triggers the first TestFlight build.
- iOS signing certificates and provisioning profiles fetched (and created on demand) by the Codemagic CLI from App Store Connect, then applied to the Xcode project — no certificates to shuffle between machines by hand.
- Codemagic workflows for iOS beta builds, Shorebird patch builds, FlutterFire reconfiguration,
and running an arbitrary Fastlane lane — all launchable from your terminal via
codemagic.sh, which streams status and opens the build page. - Android release lane that builds the bundle, packages native debug symbols and the R8 mapping,
uploads them alongside the
.aab, and tags the commit. - Build numbers and build stamps generated consistently across platforms; Sentry releases
published with matching
distvalues so stack traces symbolicate. - Firebase Test Lab integration for running integration tests on real devices.
- Slack notifications for build outcomes.
- App Store metadata, categories, content rating, privacy details, export-compliance answers,
copyright and beta review contact live in
ios/fastlaneand are uploaded withfastlane ios update_metadata. - Play Store listing graphics and changelogs are assembled from
assets/dev/androidandCHANGELOG.mdand uploaded as part of the Android release lane. - Screenshots are generated from golden tests (multi-language, per store size class) and re-uploaded on every release, so listings never drift from the app.
- Save one base icon;
dart run scripts/app_icon_flavours.dartstampsDEV/STGlabels onto it. flutter_launcher_iconsandflutter_native_splashthen generate every platform size, and the Play listing icon is copied into place.- An on-screen flavor banner makes it obvious which build you are looking at.
Riverpod, go_router, Freezed and json_serializable wiring; flutter_localizations with
generated ARB localizations; build-time and runtime env files per flavor; a permissions checklist
covering the Xcode project, AndroidManifest.xml and the iOS Podfile preprocessor flags;
unit, widget, golden and integration test scaffolding; lint configuration with custom_lint
and riverpod_lint; and IntelliJ live templates.
The trade-off is that all of this assumes a particular set of conventions — secrets under
~/.secrets, Ubuntu as the development host, Codemagic for macOS builds — and you supply your own
accounts for every service involved.
See Prerequisites for what you need to set up once before the first project.
Before using this template you need to set up your environment. It is a one-off task.
Once it's done, follow the check-list:
- Login to Google Cloud, Firebase console, and Apple Developer portal and make sure there are no pending usage agreements to be signed
- Log in to GitHub and open main repo page
- Click "Use this template / Create a new repository"
- Important: Use flutter
lowercase_with_underscoresnaming convention for your repository/project name - Important: Use SSH URL (
git@github.com...) when cloning the new repository for CI/CD integrations to work correctly cdto the project directory in your bash console- Run
./setup.shand answer the prompts (note: the process may take about an hour) - Open build.gradle.kts and update
targetSdkaccording to
Google API level requirements
Release to Internal Google Play Console track:
bundle exec fastlane android internalRelease staging flavor to Apple Test Flight (on Codemagic):
./codemagic.sh ios-beta stgQuick release (no tests, no Shorebird) to Apple Test Flight (on Codemagic):
./codemagic.sh ios-beta stg trueBuild Android app locally and submit to Test Lab to run integration tests:
pushd android
bundle exec fastlane android test_lab
popdBack up the source code:
mkdir -p ~/.backups
zip -r ~/.backups/$(basename "$PWD")-$(date +"%Y%m%d%H%M%S").zip ./The original label which is shown on the screen (under the app icon) is
stored as APP_SCREEN_LABEL variable in the project's .env.build file.
Run the following script after updating the label:
pushd ios
bundle exec fastlane ios update_app_screen_label
popd
pushd android
bundle exec fastlane android update_app_screen_label
popdSave the original base icon as assets/dev/app_icon.prod.png,
tweak scripts/app_icon_flavours.dart to your liking, and run:
echo create flavoured icons
dart run scripts/app_icon_flavours.dart
echo generate smaller icons from the original one
dart run flutter_launcher_icons
echo revert the unnecessary changes made by 'flutter_launcher_icons' plugin
sed -i 's/ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = AppIcon;/ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;/' ios/Runner.xcodeproj/project.pbxproj
echo make a copy for the app page assets in Google Store
cp -r web/icons/Icon-512.png assets/dev/android/en-US/images/icon.pngThe checklist for adding a new permission:
- Update Xcode project
- Uncomment the permission in
android/app/src/main/AndroidManifest.xml - Enable corresponding preprocessor in
ios/Podfile'sGCC_PREPROCESSOR_DEFINITIONS
Local reference files:
These are configured once (not per project).
Note: This instruction uses a convention of storing the secrets in .secrets directory in user's $HOME.
The directory layout is as follows:
~/.secrets/{service-or-product}/{secret-file}for generic secrets (such as access tokens and passwords)~/.secrets/app/{app_name}/{secret-file}for application secrets (such as push certificates)
All env variables from this document (except PATH and related) are defined in ~/.secrets/.bashrc_creds.
Call it from your .bashrc. For example source $HOME/.secrets/.bashrc_creds.
Create the directory, an empty env variables file, the script for backing up secrets, and a password for backups:
mkdir -p ~/.secrets
pushd ~/.secrets
# Create an empty file for the env variables
[ ! -f ".bashrc_creds" ] && touch ".bashrc_creds"
# Create password for secrets backups
[ ! -f "backup-pass" ] && openssl rand -base64 8 > "backup-pass"
# Create a backup script
echo 'pushd ~/.secrets; zip -r -P "$(<backup-pass)" ~/.backups/secrets-$(date +"%Y%m%d%H%M%S").zip ./; popd' > backup.sh
chmod +x backup.sh
popd Note the password from backup-pass somewhere safe and use backup.sh to back up
your ~/.secrets directory content to ~/.backups directory as a password-protected zip file.
It is recommended to create a backup every time you add or update a secret. Rehearse the restoration at least once.
Do not change proposed variable names. Some tools, such as Fastlane and Sentry CLI, implicitly rely on some of them.
Install Flutter and Android Studio, if you haven't done it yet.
Make sure you have installed the following basic toolset:
sudo apt-get install curl sed jq yq git ruby python3 python-is-python3 pipx uuidgen openjdk-17-jdkMake sure you have correctly set JAVA_HOME
(the path may differ, make sure you have the correct one):
# ~/.bash_profile
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64Important: make sure Flutter knows where the Java is:
flutter config --jdk-dir /usr/lib/jvm/java-17-openjdk-amd64Fastlane is a command-line tool written in Ruby that automates common tasks in iOS and Android development workflows, such as building, testing, code signing, and deploying apps to the App Store and Play Store.
Make sure your Ruby gems live in your local user space to avoid unexpected file permission issues:
# ~/.bash_profile
export GEM_HOME="$HOME/.gems"
export PATH="$HOME/.gems/bin:$PATH"Then install Fastlane
gem install bundler fastlaneInstall GitHub CLI.
Log in and add permissions:
gh auth login
gh auth refresh -h github.com -s delete_repo -s admin:public_keyCreate your personal and CI/CD authentication keys:
# Personal
ssh-keygen -t ed25519 -P "" -C "$(gh api user --jq '.login')"
gh ssh-key add $HOME/.ssh/id_ed25519.pub --title 'Personal'
# CI/CD
mkdir -p $HOME/.secrets/github
ssh-keygen -t ed25519 -P "" -f $HOME/.secrets/github/cicd_id_ed25519 -C "$(gh api user --jq '.login')"
gh ssh-key add $HOME/.secrets/github/cicd_id_ed25519.pub --title 'CICD'Add the path to your GitHub CI/CD key to the env variable:
# ~/.secrets/.bashrc_creds
export CICD_GITHUB_SSH_KEY_PATH="$HOME/.secrets/github/cicd_id_ed25519"You can check your existing GitHub keys here.
Slack is used to send build status notifications from Codemagic.
Create an account and install Slack:
sudo snap install slackCreate #cicd-all public channel.
Update this project's files if you want another name.
Assuming Apple Developer Program membership is active.
Get your "Team ID" from Apple Developer Portal.
Get your App Store Connect (former iTunes Connect - itc) team ID from App Store Connect.
Create and download App Store Connect API (team) key for CI/CD integration. Use App Manager role (or Admin if feeling lucky). Take note of the Issuer ID and the Key ID.
Store the key as $HOME/.secrets/apple/AuthKey_{YOUR_KEY_ID}.p8
Some fastlane actions still require username/password authentication.
Save your iTunes password to $HOME/.secrets/apple/itunes-pass (in one line).
Set env variables:
# ~/.secrets/.bashrc_creds
export APPLE_DEV_TEAM_ID=...
export APP_STORE_CONNECT_TEAM_ID=...
export APP_STORE_CONNECT_ISSUER_ID=...
export APP_STORE_CONNECT_KEY_IDENTIFIER=...
export APP_STORE_CONNECT_PRIVATE_KEY_PATH="$HOME/.secrets/apple/AuthKey_${APP_STORE_CONNECT_KEY_IDENTIFIER}.p8"
# Your iTunes Id
export ITUNES_ID=...
export ITUNES_PASSWORD_PATH="$HOME/.secrets/apple/itunes-pass"
# This should be your full name if you are an individual developer
export APP_STORE_COMPANY_NAME=...Make sure you have a suitable Google Cloud billing account.
Install gcloud CLI.
Install firebase CLI.
Install flutterfire tool:
dart pub global activate flutterfire_cliIf the Pub Bin is not on your PATH (you'll see the prompt after the flutterfire activation), fix that.
Create a Google Cloud service account and give it access to your Google Play Console (use this instruction).
You can use any of your Google Cloud projects for the service account (not specific to the app).
Save your JSON access key to $HOME/.secrets/google/{YOUR_JSON_FILE_NAME}.
Generate a code-signing key pair for apps uploads to Play Console:
mkdir -p "$HOME/.secrets/google"
openssl rand -base64 8 >> "$HOME/.secrets/google/play-upload-keystore-pass"
keytool -genkeypair \
-keyalg RSA \
-keysize 2048 \
-validity 10000 \
-alias upload \
-keystore "$HOME/.secrets/google/play-upload-keystore.jks" \
-storepass $(cat "$HOME/.secrets/google/play-upload-keystore-pass") \
-keypass $(cat "$HOME/.secrets/google/play-upload-keystore-pass")Add env variables:
# ~/.secrets/.bashrc_creds
export GCLOUD_BILLING_ACCOUNT_ID=...
export SUPPLY_JSON_KEY="$HOME/.secrets/google/{YOUR_JSON_FILE_NAME}"
export PLAY_CONSOLE_UPLOAD_KEYSTORE="$HOME/.secrets/google/play-upload-keystore.jks"
export PLAY_CONSOLE_UPLOAD_KEYSTORE_PASS="$HOME/.secrets/google/play-upload-keystore-pass"Register with OneSignal.
Do not create an app, the template setup script will do this for you.
Open you organisation in the organisation dashboard,
and copy the org ID from the URL (must be something like a123456f-42cd-3e14-a360-123ab456cdef).
Go to "Keys & IDs", create an API Key, and store it in $HOME/.secrets/onesignal/api-token file.
Add env variables:
# ~/.secrets/.bashrc_creds
export ONESIGNAL_ORG_ID=...
export ONESIGNAL_API_KEY_PATH="$HOME/.secrets/onesignal/api-token"Go to your account setting and enable Slack integration.
Save Codemagic API token to $HOME/.secrets/codemagic/auth-token file and add env variable:
# ~/.secrets/.bashrc_creds
export CM_API_TOKEN_PATH="$HOME/.secrets/codemagic/auth-token"Install Codemagic CLI suite:
pipx install codemagic-cli-tools
pipx ensurepathRegister with Sentry.
Create two auth tokens in User Auth Tokens,
and save them in $HOME/.secrets/sentry directory:
api-token-devfile; roles: Projects: Admin; Organisation: Read (used locally for initial project setup)api-token-cifile; roles: Release: Admin; Organisation: Read (used locally and on CI server)
Add variables:
# ~/.secrets/.bashrc_creds
export SENTRY_PROJECTS_ADMIN_TOKEN_PATH="$HOME/.secrets/sentry/api-token-dev"
export SENTRY_CI_TOKEN_PATH="$HOME/.secrets/sentry/api-token-ci"
export SENTRY_ORG="{organization-slug}"
export SENTRY_TEAM="{default-team-slug}"Install GitHub integration.
Shorebird is a service that allows patching production apps without going through the app store review process.
Create a dev account with Shorebird.
Create CI auth token:
shorebird login:ciSave the token to your $HOME/.secrets/shorebird/auth-token and add an env variable:
# ~/.secrets/.bashrc_creds
export SHOREBIRD_TOKEN_PATH="$HOME/.secrets/shorebird/auth-token"Export your contact details for submission to the App and Play store.
# ~/.secrets/.bashrc_creds
export DEV_FIRST_NAME=...
export DEV_LAST_NAME=...
export DEV_PHONE=...
export DEV_EMAIL=...
export DEV_WEBSITE=...
export DEV_FULL_NAME=...
export DEV_ADDRESS_LINE_1=...
export DEV_ADDRESS_LINE_2=...
export DEV_CITY=...
export DEV_STATE=...
export DEV_COUNTRY=...
export DEV_ZIP=...-
migrate from CocoaPods; permission handler plugin depends on it: update it and this readme
-
use branch name for flavor instead of
codemagic.shparameter or env variables -
finish Andrea's 6 pre-release steps integration
-
enable deep links for iOS / Android (mention this in the readme)
-
collect tips from "large screen case study" https://medium.com/flutter/developing-flutter-apps-for-large-screens-53b7b0e17f10
-
address security scan issue with API tokens in Firebase config files
-
Add scaffolding:
- basic 'lib' folder structure
- force update plugin
- main menu
- feedback form
- settings screen (a couple of fake settings paired with the local storage)
- 'about' screen (product name and version, licensing information)
-
Add integrations:
- Firebase Remote config
-
Screenshots generation framework:
- Move from discontinued
golden_toolkit - Implement proper fonts loading (maybe it'll fix itself in Alchemist)
- Implement device frames in screenshot generator
- Move from discontinued
-
consider integration with self-checkin service for beta testers, for both Android and iOS, like Boarding, but more stable
-
See how an automatic translation service can be added (or built via an AI API)