# Build Flutter iOS Apps in CI on a Mac Runner

Canonical: https://figment.so/blog/mac-flutter-ios-ci-build

Pin Flutter with FVM, run flutter pub get before pod install, build with flutter build ipa and a committed ExportOptions.plist, sign with Fastlane Match in read-only mode, and upload with fastlane pilot.

**Pin Flutter with FVM, run `flutter pub get` before `pod install`, build with `flutter build ipa --export-options-plist`, sign with Fastlane Match in read-only mode, and upload with `fastlane pilot`.** The steps below run on a self-hosted Mac registered as a GitHub Actions runner.

Flutter iOS CI stitches four tools together on one Mac (Flutter, CocoaPods, Ruby and Xcode) in a specific order, documented in the [Flutter iOS deployment guide](https://docs.flutter.dev/deployment/ios). The extra CI problem is Flutter SDK drift between developers and runners. FVM (Flutter Version Management) fixes that.

## What does the Mac runner need?

Xcode, CocoaPods, Ruby and Flutter. `flutter build ipa` is not one command. It drives several underneath:

1. `flutter pub get` fetches Dart packages and writes the Flutter-engine Podfile entries.
2. `pod install` resolves the CocoaPods graph for the iOS plugins.
3. `xcodebuild archive` builds the generated `Runner.xcworkspace`.
4. `xcodebuild -exportArchive` produces the signed IPA using your `ExportOptions.plist`.

This workflow installs Flutter on the runner through FVM, so the only preinstalled requirements are Xcode and a Ruby toolchain.

## How do I pin the Flutter version with FVM?

Commit `.fvmrc` at the repo root so every developer and every CI run compiles against the same release:

```json
{
  "flutter": "3.24.3",
  "flavors": {}
}
```

Install FVM on the runner from the current tap. Per the [FVM installation docs](https://fvm.app/documentation/getting-started/installation), the tap is `btwld/fvm` (migrated from the older `leoafarias/fvm`):

```yaml
- name: Install FVM
  run: |
    brew tap btwld/fvm
    brew install btwld/fvm/fvm

- name: Install pinned Flutter
  run: fvm install
```

After `fvm install`, call Flutter as `fvm flutter` in every later step. FVM proxies the pinned version, so you do not export a path manually.

## Why must pub get run before pod install?

Because `flutter pub get` writes plugin entries into `ios/Podfile`. If `pod install` runs first, CocoaPods either fails or reuses a stale cached graph and ships the wrong plugin version.

```yaml
- name: Dart dependencies
  run: fvm flutter pub get

- name: CocoaPods cache
  uses: actions/cache@v4
  with:
    path: ios/Pods
    key: pods-${{ runner.os }}-${{ hashFiles('ios/Podfile.lock') }}
    restore-keys: pods-${{ runner.os }}-

- name: CocoaPods install
  run: cd ios && pod install
```

Keying the cache on `Podfile.lock` means any plugin bump invalidates it, and unchanged graphs skip the network. For a deeper cache design, see [Caching CocoaPods across Mac CI runner jobs](/blog/mac-cocoapods-cache-ci-runner).

## How do I set up export options and signing?

Commit `ios/ExportOptions.plist`. A minimal App Store version:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>method</key><string>app-store</string>
  <key>teamID</key><string>YOUR_TEAM_ID</string>
  <key>uploadBitcode</key><false/>
</dict>
</plist>
```

Then build:

```bash
fvm flutter build ipa --release \
  --export-options-plist=ios/ExportOptions.plist
```

The IPA lands in `build/ios/ipa/`. The signing identity and provisioning profile must be in place before this step. Handle that with Fastlane Match against a private, encrypted certificates repo (see [Fastlane Match for CI Code Signing](/blog/mac-fastlane-match-ci-codesigning)). Never export your whole shell environment to disk, and never import provisioning profiles into Keychain. Profiles are files that Xcode reads from `~/Library/MobileDevice/Provisioning Profiles/`.

## What does the full workflow look like?

```yaml
# .github/workflows/flutter-ios.yml
name: Flutter iOS CI

on:
  push:
    branches: [main, 'release/**']
  pull_request:
    branches: [main]

jobs:
  build-ios:
    runs-on: [self-hosted, macOS, figment]   # label your runner to match
    steps:
      - uses: actions/checkout@v4

      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: '3.3'
          bundler-cache: true

      - name: Install FVM
        run: |
          brew tap btwld/fvm
          brew install btwld/fvm/fvm

      - name: Install pinned Flutter
        run: fvm install

      - name: Dart dependencies
        run: fvm flutter pub get

      - uses: actions/cache@v4
        with:
          path: ios/Pods
          key: pods-${{ runner.os }}-${{ hashFiles('ios/Podfile.lock') }}
          restore-keys: pods-${{ runner.os }}-

      - name: CocoaPods install
        run: cd ios && pod install

      - name: Sync signing (Fastlane Match, read-only)
        run: bundle exec fastlane match appstore --readonly
        env:
          MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
          MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }}
          APP_STORE_CONNECT_API_KEY_ID: ${{ secrets.ASC_KEY_ID }}
          APP_STORE_CONNECT_API_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
          APP_STORE_CONNECT_API_KEY_CONTENT: ${{ secrets.ASC_PRIVATE_KEY }}

      - name: Build IPA
        run: |
          set -euo pipefail
          fvm flutter build ipa --release \
            --export-options-plist=ios/ExportOptions.plist

      - name: Upload to TestFlight
        run: |
          set -euo pipefail
          IPA=$(ls build/ios/ipa/*.ipa | head -1)
          bundle exec fastlane pilot upload --ipa "$IPA"
        env:
          APP_STORE_CONNECT_API_KEY_ID: ${{ secrets.ASC_KEY_ID }}
          APP_STORE_CONNECT_API_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID }}
          APP_STORE_CONNECT_API_KEY_CONTENT: ${{ secrets.ASC_PRIVATE_KEY }}
```

`set -euo pipefail` makes each script step stop on the first failure, so a broken archive never reaches TestFlight. This is a reference workflow to adapt, not a measured benchmark.

## What should I check before the first run?

- [ ] `.fvmrc` committed with the target Flutter version.
- [ ] `ios/ExportOptions.plist` committed with the correct `teamID`.
- [ ] Fastlane Match repo created; certificates and profiles pushed.
- [ ] GitHub Secrets set: `MATCH_PASSWORD`, `MATCH_GIT_BASIC_AUTHORIZATION`, `ASC_KEY_ID`, `ASC_ISSUER_ID`, `ASC_PRIVATE_KEY`.
- [ ] Self-hosted runner registered with a label matching the `runs-on` list.
- [ ] Xcode version on the runner matches your minimum deployment target. On an Intel Mac VM, stay on Xcode 26.3 or earlier.

## Is a rented Mac cheaper than GitHub-hosted macOS for Flutter builds?

Usually, above roughly 31 builds a month. This worksheet uses an example volume, so replace it with yours. Say your team runs 40 Flutter iOS builds a week. On GitHub-hosted macOS at $0.062/minute, a 20-minute build costs 20 × $0.062 = $1.24 per run, or about 40 × 4.33 × $1.24 ≈ $215 a month before any queueing.

- An Apple Silicon Mac VM at $39 a month flat breaks even at $39 ÷ $1.24 ≈ 31 runs a month.
- A Dedicated M4 Pro at $349 a month breaks even at $349 ÷ $1.24 ≈ 281 runs a month, and also gives you a whole Mac for parallel builds.

The sibling guide [GitHub-hosted vs self-hosted Mac runner costs](/blog/mac-github-hosted-vs-self-hosted-cost) steps through break-even with queue time included.

## Should a Flutter iOS runner be a VM or a whole Mac?

For current Xcode, use the [Apple Silicon Mac VM](/mac-hosting#apple-silicon-vm) ($39 a month, or $6 a day). Move to the [Dedicated M4 Pro 48 GB](/mac-hosting#dedicated-m4-pro) ($349 a month) if you build in parallel or the Flutter app is large. The [Intel Mac VM](/mac-hosting#intel-vm) ($25 a month) runs macOS Sequoia, so it covers Xcode 26.0 to 26.3 only. Xcode 26.4 and later need an Apple silicon plan. You install the runner, FVM and Fastlane yourself.

**Related guides:** [Send Slack alerts for iOS CI build status](/blog/mac-ci-slack-notification-build-status) · [GitHub-hosted vs self-hosted Mac runner costs](/blog/mac-github-hosted-vs-self-hosted-cost) · [Remote Xcode setup on Windows](/blog/mac-xcode-on-windows-remote-setup)
