# Add Fastlane to a Flutter App

Yes. An agent reads your Android and iOS build settings, writes Fastlane lanes for both stores that build from the Flutter tool, checks them and opens a PR.

[Run this on Rush](https://cloud.getrush.ai/run/add-fastlane/flutter/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent clones the app into its own cloud sandbox and reads both native projects before writing a lane. In an app like simplezhli/flutter_deer, `pubspec.yaml` names the package `flutter_deer` at `version: 1.3.3+22` with a Dart SDK constraint of `>=3.4.0 <4.0.0` and Flutter `>=3.19.0`. On Android, `android/app/build.gradle` sets `applicationId "com.weilu.deer"`, `targetSdkVersion 37`, reads `versionCode` and `versionName` from `local.properties`, which the Flutter tool fills from `pubspec.yaml`, and defines a `release` signing config that loads `app/key.properties` for `storeFile`, `storePassword`, `keyAlias` and `keyPassword`; both the `debug` and `release` build types use it, and `release` also turns on `minifyEnabled` and `shrinkResources` with `proguard-rules.pro`. `android/settings.gradle` pins the Android Gradle plugin at `9.1.0` and Kotlin at `2.4.0`. On iOS, `ios/Podfile` sets `platform :ios, '15.0'`, the project is `Runner.xcworkspace` with one shared scheme, `Runner`, a `RunnerTests` target, `PRODUCT_BUNDLE_IDENTIFIER` of `com.weilu.flutterDeer` and `CODE_SIGN_STYLE = Automatic`.

It also reads what already automates builds. `.github/workflows/flutter-drive.yml` runs `flutter drive` on an iOS simulator and an Android emulator with `subosito/flutter-action@v2` at Flutter `3.47.4`, plus an accessibility test, and `flutter-web-deploy.yml` builds the web target and publishes it to `gh-pages`. There is no `Gemfile`, no `fastlane/` directory under either platform and no store upload anywhere, so release builds are the two commands the README gives, `flutter build apk` and `flutter build ios`, run by hand.

The agent writes `android/Gemfile` and `ios/Gemfile` with `fastlane` as the one gem, `android/fastlane/Appfile` with `package_name("com.weilu.deer")` and a `json_key_file` read from an environment variable, and `ios/fastlane/Appfile` with the bundle identifier. The Android `Fastfile` gets a `build` lane that runs `flutter build appbundle --release` from the project root through `sh`, so the version code and name keep coming from `pubspec.yaml` and the signing config keeps coming from `key.properties`, and an `internal` lane that calls `upload_to_play_store` on the internal track with the bundle it produced. The iOS `Fastfile` gets a `build` lane that runs `flutter build ipa --release` and a `beta` lane that calls `upload_to_testflight` with an App Store Connect API key read from environment variables, because automatic signing with a personal Apple ID does not work on a build machine. A `match` setup is described in the pull request but not created, since it needs a certificates repository the team owns.

It then validates what it can on Linux: `bundle install` in both directories, `bundle exec fastlane lanes` to prove the Fastfiles parse and list the lanes, and after installing Flutter at the version the workflows pin, `flutter pub get` and `flutter analyze` to confirm the Dart side is unchanged. An Android build needs the SDK and build tools, which the agent installs with the command-line tools when the sandbox has room, running the `build` lane once to show the bundle appears under `build/app/outputs/bundle/release/`. iOS lanes cannot run on Linux and the pull request says so. It also flags that `android/app/key.properties` and `test.jks` are committed and that `.gitignore` does not exclude them, and that the `debug` build type signs with the release key, as things to resolve before the `internal` lane points at a real listing.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add Fastlane to this Flutter app for Android and iOS. Read pubspec.yaml, android/app/build.gradle, android/settings.gradle, ios/Podfile, the Xcode project settings and every workflow under .github/workflows first. Write a Gemfile, an Appfile and a Fastfile under android/fastlane and ios/fastlane. The Android build lane must run flutter build appbundle from the project root so the version and signing keep coming from pubspec.yaml and the existing signing config; add an internal lane that uploads to the Play internal track with a JSON key read from an environment variable. The iOS build lane must run flutter build ipa; add a beta lane that uploads to TestFlight using an App Store Connect API key from environment variables. Do not create certificates or a match repository; describe that setup in the pull request. Run bundle install and fastlane lanes in both directories, and run the Android build lane if the SDK can be installed. Flag any committed keystore or key properties file. Open a pull request with the lane output.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request adding six files, a `Gemfile`, an `Appfile` and a `Fastfile` under each platform, and changing nothing in `lib/`, `build.gradle` or the Xcode project. The description lists the four lanes with the command each runs, the environment variables the upload lanes read, and the `fastlane lanes` output from both directories.

The run's record keeps the `bundle install` runs, the lane listing and, when the Android SDK installed, the `build` lane's output with the path of the app bundle it wrote, so a reviewer can see the lane really drives the Flutter tool rather than a Gradle task that would bypass `pubspec.yaml` versioning.

Before merging, a reviewer decides where the Play JSON key and the App Store Connect key live in their CI, whether to add `match` and a certificates repository, and what to do about the committed `key.properties` and `test.jks`, which the pull request names but does not delete.

## Run it on every new Flutter repository

A team that creates a Flutter app a quarter wants every one of them to ship the same way. A handler on your server receives GitHub's organisation `repository` webhook, checks that the new repository has a `pubspec.yaml` with `flutter` in its dependencies, and sends one `POST /o/{org}/sessions` with the prompt above and that repository in `resources`, with a `request_id` that is a UUID v5 of the repository id so a redelivered webhook never starts a second run.

Each run opens one pull request on its own branch in the new repository. One that cannot install the Android SDK still opens the pull request with the Fastfiles and the `fastlane lanes` output, and says in the description which lane it could not exercise, so the first person to touch the repository knows what remains.

## Why run it on Rush?

Fastlane for Flutter is mostly about not fighting the Flutter tool: a lane that calls Gradle or `xcodebuild` directly loses the version from `pubspec.yaml` and the signing config the project already has. The agent reads those files and writes lanes that go through `flutter build`, then proves the Ruby side parses and, where the sandbox allows, that the Android lane produces a bundle, with the commands and their output kept in the run instead of in someone's terminal history.

The same request sent to every mobile repository in an organisation returns one pull request each, built from that app's own identifiers, signing setup and workflows. The committed keystore in one app and the automatic signing in another are surfaced per repository, which is the inventory a release engineer would otherwise build by hand.

## Frequently asked questions

### Will the lanes change how the app is versioned?

No. Both build lanes run `flutter build`, so `versionCode` and `versionName` keep coming from `version: 1.3.3+22` in `pubspec.yaml` through `local.properties`, as `build.gradle` reads them today. Fastlane's own `increment_build_number` actions are not used.

### Can it set up iOS code signing?

It writes the `beta` lane to use an App Store Connect API key from environment variables and explains `match` in the pull request, but creates no certificates, profiles or certificates repository. Those need an Apple developer account and a private repository the team owns, which the agent does not have and should not invent.

### Does it run the iOS lane?

No. The sandbox is Linux, so `flutter build ipa` and `upload_to_testflight` cannot run there. The agent runs `bundle exec fastlane lanes` in `ios/` to prove the Fastfile parses and marks the lane as untested in the description.

### What about the committed keystore?

The pull request names `android/app/key.properties` and `test.jks` and notes that `.gitignore` does not exclude them and that the `debug` build type signs with the same key. It does not delete them, because a working build depends on them until a replacement keystore and secret store exist.

### Can it upload to the stores from the run?

Only if the Play JSON key and App Store Connect key are available to the run, which the prompt above does not ask for. The upload lanes are written to read them from the environment so a CI job with those secrets can call `fastlane internal` or `fastlane beta` after the pull request merges.

## More Flutter jobs

- [Add GitHub Actions CI to a Flutter App](https://getrush.ai/run/add-github-actions-ci/flutter/)
- [Add i18n to a Flutter App](https://getrush.ai/run/add-i18n/flutter/)
- [Add Integration Tests to a Flutter App](https://getrush.ai/run/add-integration-tests/flutter/)

## More jobs like this: Hand off a long task

- [Add Featured Images to a Gatsby Blog](https://getrush.ai/run/add-featured-images/gatsby/)
- [Add File Uploads to an AdonisJS App](https://getrush.ai/run/add-file-uploads/adonisjs/)
- [Add File Uploads to a CodeIgniter 4 App](https://getrush.ai/run/add-file-uploads/codeigniter/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
