Skip to content
Blog

Guides 4 min read

How to release and patch a Flutter add-to-app module

For teams adding Flutter one screen at a time to a big native Android or iOS app.

Abhishek Doshi

Developer Relations Engineer

Part 1 covered the change: your Flutter module now has its own release version, separate from the host app’s. A patch follows the module build, not the host app’s version.

This part is the walkthrough: you’ll release the module, patch it, and test the patch before users see it. If your module was built on an older version, the last section covers moving it over.

You need Shorebird 1.6.142 or newer and Flutter 3.47.9 or newer. Run shorebird upgrade to update the CLI.

Release once: shorebird release aar and ios-framework with --release-version

Run shorebird init in your module, then release it with a version you pick:

# Android
shorebird release aar --release-version 2.4.0+1

# iOS
shorebird release ios-framework --release-version 2.4.0+1

The version belongs to the module, not your host app. That trips people up. Use the version from the module’s pubspec.yaml, or a CI build number. You can’t reuse one on the same platform. Android and iOS can share one if both builds use the same Flutter version. It can have ASCII letters, digits, ., _, + and -, up to 128 characters.

The release lands in a release directory. On Android that’s a local Maven repo with the aar inside. On iOS it’s App.xcframework and ShorebirdFlutter.xcframework. Build your host app from that exact directory. Don’t run flutter build on the module again for the store build. Patches only install on the module build shorebird release made, so a second build never gets them.

Shorebird patches the prebuilt AAR on Android and the embedded XCFrameworks on iOS. While you develop on Android, a source dependency is fine, but switch to the AAR before you release. Swift Package Manager isn’t supported for iOS releases and patches yet. The Android and iOS guides have the full setup, including CI jobs that keep the release directory as a build artifact.

Patch with the same version:

shorebird patch aar --release-version 2.4.0+1 --track=stable
shorebird patch ios-framework --release-version 2.4.0+1 --track=stable

To see if it worked, look for the patch check line in the device logs. release_version is your module’s version. If it’s different from the host app’s, you’ll also see host_version.

Testing and rolling out: QA builds, tracks and multiple entrypoints

In add-to-app, the host app usually belongs to another team, and waiting on a full QA build for every patch is a drag. Tracks fix that.

The module reads a track from the host app at startup and checks for patches on it. Store builds pass no track, so they stay on stable. To set it up, add shorebird_code_push, set auto_update: false in the module’s shorebird.yaml, and check for updates on whatever track the host passes as --shorebird-track=<name>. Do this before shorebird release, since it has to be part of the release.

You can test two ways:

  • Test a patch locally: build the host app yourself against the module release, publish to your own track like dev-<your-name>, and try it on a device.
  • Give QA a build: add a QA build type or configuration to the host app that passes qa, publish patches to qa, and promote them once QA signs off.
shorebird patch aar --release-version 2.4.0+1 --track qa

# After QA signs off
shorebird patches promote --release-version 2.4.0+1 --patch-number 2

After you promote, users get the exact patch QA tested. No rebuild. The catch is that the QA build and the store build must contain the same module release. Otherwise they’re separate releases with separate patches. Keep QA-only differences, like server URLs, in the host app and pass them to the module at startup.

You can also ramp a patch on stable. Add --rollout 10 to shorebird patch or shorebird patches promote and it goes to 10% of devices on the track. Raise it once things look fine. More in Percentage-based rollouts.

If the host app starts the module through more than one Dart entrypoint or engine, for example with FlutterEngineGroup, one patch covers all of them. The host app’s native code names the entrypoints, so don’t remove or rename one in a patch, and keep @pragma('vm:entry-point') on each. With auto_update off, call your update check from every entrypoint that could run first. The odd cases are in Multiple Dart entrypoints and engines.

Upgrading from modules built on older versions

If your module was built with Shorebird older than 1.6.142 or Flutter older than 3.47.9, it can’t have its own version yet. Devices report the host app’s version, so --release-version has to match it: versionName+versionCode on Android, CFBundleShortVersionString+CFBundleVersion on iOS.

If CI already passes the host app’s version, you don’t need to change anything. Switch to a module version whenever you do your next module release.

Until the old host builds are gone, a few things to watch:

  • Don’t give a module the same version as a host app. Use a prefix like m2.4.0+1. If the two collide, devices on an old build can get patches that won’t install on them.
  • If you build with an older Flutter through --flutter-version, the same limit applies, so no module version there either.
  • Patch with Shorebird 1.6.142 or newer. Older CLIs see the version baked into the module’s shorebird.yaml as a changed asset and stop the patch in CI.

Try it on your next module release

Run shorebird upgrade, then read the Module versions guide before you cut the release. Stuck on something? Ask on Discord.

All posts
  • Guides 6 min read

    What happens when a patch fails

    A close look at how Shorebird patches fail, what your users experience when they do, and what you can do about it.

    Abhishek Doshi

    Developer Relations Engineer

  • Guides 4 min read

    Manually control your Shorebird updates

    Learn how to disable Shorebird's automatic updates and take full manual control over when and how patches roll out to your users.

    Abhishek Doshi

    Developer Relations Engineer

Ship your first patch today.

Install the CLI, create a release and send a patch. Free for 5,000 patch installs a month.

Larger team? Talk to sales