ANN Flutter Flavor — Fastlane Plugin

RubyGems License: MIT

Fastlane plugin that reads annspec.yaml and provides lanes for building, signing, uploading and testing all Flutter flavors across Android, iOS and Web — without writing repetitive Fastfile boilerplate for each flavor.


Installation

Add to your Pluginfile:

gem 'ann-flavor-flutter'

Then run:

bundle install

Or add directly via Fastlane:

fastlane add_plugin ann_flavor_flutter

Quick start

# Fastfile
lane :deploy_android do
  ann_compile_build(platform: :android, build_config: "release")
  ann_upload_to_play_store(platform: :android)
end

lane :deploy_ios do
  ann_compile_build(platform: :ios, build_config: "release")
  ann_upload_to_app_store(platform: :ios)
end
bundle exec fastlane deploy_android
bundle exec fastlane deploy_ios

Actions

ann_compile_build — Build all flavors for a platform

ann_compile_build(
  platform:               :android,     # :ios, :android, or :web
  build_config:           "release",    # "debug", "profile", "release"
  sub_command:            "appbundle",  # "apk", "appbundle", "ipa", "web"
  flavor:                 "production", # Comma-separated. Omit to build ALL flavors
  clean:                  false,
  main_file:              "lib/main.dart",
  skip_sound_null_safety: false,
  skip_code_sign:         false,
  export_options_plist:   "",           # iOS only
  additional_parameter:   "",
  spec_file:              nil           # Custom path to annspec.yaml (optional)
)

Examples:

ann_compile_build(platform: :android)                                         # All Android flavors
ann_compile_build(platform: :ios, flavor: "production,staging")               # Specific iOS flavors
ann_compile_build(platform: :web, sub_command: "web", clean: true)            # Web with clean

ann_upload_to_play_store — Upload Android to Google Play

ann_upload_to_play_store(
  flavor:    "production",   # Specific flavor(s). Omit for all
  clean:     false,
  spec_file: nil
)

ann_upload_to_app_store — Upload iOS to App Store

ann_upload_to_app_store(
  flavor:    "production",
  clean:     false,
  spec_file: nil
)

ann_upload_to_firebase — Deploy web to Firebase Hosting

ann_upload_to_firebase(
  flavor:    "web",
  clean:     false,
  spec_file: nil
)

ann_run_tests — Run integration tests

ann_run_tests(
  platform:       :android,
  test_spec_file: nil
)

ann_open_emulators — Start emulators/simulators

ann_open_emulators(
  platform:       :android,
  test_spec_file: nil
)

annai_upgrade_setup — Maintenance setup

annai_upgrade_setup              # Skip if already up to date
annai_upgrade_setup(force: true) # Force run

annai_cleanup — Clean build artifacts

annai_cleanup
annai_cleanup(force: true)

Configuration

The plugin reads annspec.yaml from your Flutter project root. Keys used by Fastlane actions:

annai_app:
  android:
    default:
      signature:
        key_file: "../annai_app_data/keys/android/my_key.properties"
    stores:
      google_play:
        api_key: "../annai_app_data/keys/android/google-api-key.json"
    flavor:
      production:
        main_file: "lib/flavors/main_prod.dart"
        version_name: 2.1.0
        version_code: 20100

  ios:
    default:
      team_id: "XXXXXXXXXX"
    stores:
      app_store:
        api_key: "../annai_app_data/keys/ios/apple_api_key.json"
        export_options_plist: "../annai_app_data/keys/ios/exportOptions.plist"
    flavor:
      production:
        apple_id: "1234567890"
        main_file: "lib/flavors/main_prod.dart"
        version_name: 2.1.0
        version_code: 20100

See the Gradle plugin README for the complete annspec.yaml field reference.


Typical CI/CD Fastfile

default_platform(:android)

platform :android do
  lane :build do
    ann_compile_build(platform: :android, build_config: "release", sub_command: "appbundle", clean: true)
  end

  lane :deploy do
    ann_upload_to_play_store
  end

  lane :test do
    ann_open_emulators(platform: :android)
    ann_run_tests(platform: :android)
  end
end

platform :ios do
  lane :build do
    ann_compile_build(platform: :ios, build_config: "release", sub_command: "ipa")
  end

  lane :deploy do
    ann_upload_to_app_store
  end
end

Testing

The plugin has an RSpec test suite:

# From ann-flavor-tooling root
cd plugins/ann-flavor-fastlane && bundle exec rake spec

# Or via the publish script (also saves results + posts Check Run)
cd ../.. && ./scripts/publish.sh fastlane 0.1.3

Publishing

Publishing is managed from the ann-flavor-tooling root:

cd ../..
./scripts/publish.sh fastlane 0.1.3

Requirements

  • Fastlane >= 2.232.2
  • Ruby >= 3.0
  • Flutter project with annspec.yaml at the project root


License

MIT © ANN Solutions