Flutter Build
Flutter allows you to build cross-platform apps from a single codebase. This recipe demonstrates how to build iOS, Android, and macOS apps using Flutter, including dependency installation, build compilation, and macOS code signing and distribution.
Flutter iOS Build YAML
Section titled “Flutter iOS Build YAML”name: Flutter iOS Buildplatform: flutter
environment: flutter: "3.24.0"
triggers: - push - pull_request
steps: - name: Install dependencies run: flutter pub get
- name: Build iOS run: flutter build iosFlutter Cross-Platform Build
Section titled “Flutter Cross-Platform Build”name: Flutter Mobile Buildplatform: flutter
environment: flutter: "3.24.0"
triggers: - push - pull_request
steps: - name: Install dependencies run: flutter pub get
- name: Build Android run: flutter build apk
- name: Build iOS run: flutter build iosBuild Workflow
Section titled “Build Workflow”The typical Flutter build workflow includes:
- Dependency Installation:
flutter pub getresolves all Pub dependencies specified inpubspec.yaml - iOS Build:
flutter build iosgenerates an iOS app bundle - Android Build:
flutter build apkgenerates an Android APK
Key Points
Section titled “Key Points”- pubspec.yaml: Your Flutter project's manifest file, similar to
Package.swiftfor native Swift orpackage.jsonfor Node.js - pub get: Downloads and installs all dependencies from pub.dev
- Platform-specific builds: Flutter can generate both iOS and Android builds from the same source code
- .fvmrc file (optional): Commit this at your repository root to pin the Flutter SDK version; if you set
environment.flutter: fvm, the agent will read the version from your.fvmrcfile
Building an iOS IPA from Flutter
Section titled “Building an iOS IPA from Flutter”When auto-signing is fully configured, you can build and export an iOS IPA directly from Flutter:
name: Flutter Build IPAplatform: flutter
environment: flutter: "3.41.8"
triggers: - push
steps: - name: Get dependencies run: flutter pub get
- name: Build iOS run: flutter build ios --release --no-codesign
- name: Create IPA run: flutter build ipa --releaseBuilding a macOS App from Flutter
Section titled “Building a macOS App from Flutter”Flutter can build Mac apps, but a Flutter pipeline always declares platform: flutter —
it can never declare platform: macos. To tell RunnerHub that a job produces a Mac
app (so it picks macOS provisioning profiles, the Mac Installer certificate, and .pkg
deploys), add the target_platform
field:
platform: fluttertarget_platform: macostarget_platform is optional, works only on Flutter pipelines, and can be set per job in
a multi-job pipeline (where it overrides the top-level value).
Recipe 1 — Mac Development build
Section titled “Recipe 1 — Mac Development build”The simplest case: build a signed .app for internal testing. flutter build macos
writes the app bundle to build/macos/Build/Products/Release/.
name: Flutter macOS Developmentplatform: fluttertarget_platform: macos
environment: flutter: "3.24.0"
triggers: - push - pull_request
steps: - name: Install dependencies run: flutter pub get
- name: Run tests run: flutter test
- name: Build macOS run: flutter build macos --release
artifacts: - build/macos/Build/Products/Release/*.appSet the app's signing type to Development in App Settings → Code Signing.
Recipe 2 — Developer ID (direct distribution outside the Mac App Store)
Section titled “Recipe 2 — Developer ID (direct distribution outside the Mac App Store)”Developer ID signing produces a .app you can distribute yourself. The build steps are
identical to Recipe 1 — only the app's signing type changes.
name: Flutter macOS Developer IDplatform: fluttertarget_platform: macos
environment: flutter: "3.24.0"
triggers: - push
steps: - name: Install dependencies run: flutter pub get
- name: Build macOS run: flutter build macos --release
# Notarization is NOT automated — run it yourself if you need it. - name: Notarize and staple run: | APP="$(ls -d build/macos/Build/Products/Release/*.app | head -1)" ditto -c -k --keepParent "$APP" build/macos/upload.zip xcrun notarytool submit build/macos/upload.zip \ --apple-id "$AC_APPLE_ID" \ --team-id "$AC_TEAM_ID" \ --password "$AC_APP_PASSWORD" \ --wait xcrun stapler staple "$APP"
artifacts: - build/macos/Build/Products/Release/*.appRecipe 3 — Mac App Store (.pkg → TestFlight / App Store)
Section titled “Recipe 3 — Mac App Store (.pkg → TestFlight / App Store)”flutter build macos produces a .app bundle and never a .pkg. TestFlight and the
App Store only accept a .pkg, so you must archive and export with xcodebuild after the
Flutter build.
name: Flutter Mac App Storeplatform: fluttertarget_platform: macos
environment: flutter: "3.24.0"
triggers: - event: push branches: - main
steps: - name: Install dependencies run: flutter pub get
- name: Build macOS run: flutter build macos --release
- name: Archive run: | xcodebuild -workspace macos/Runner.xcworkspace \ -scheme Runner \ -configuration Release \ -archivePath build/macos/Runner.xcarchive \ archive
- name: Export .pkg run: | xcodebuild -exportArchive \ -archivePath build/macos/Runner.xcarchive \ -exportOptionsPlist "$RH_EXPORT_OPTIONS_PLIST" \ -exportPath build/macos/export
artifacts: - build/macos/export/*.pkgSet the app's signing type to App Store in App Settings → Code Signing, then add a TestFlight or App Store deploy target.
Building iOS and macOS in one pipeline
Section titled “Building iOS and macOS in one pipeline”Use a multi-job pipeline and set target_platform per job:
name: Flutter iOS + macOSplatform: flutter
environment: flutter: "3.24.0"
triggers: - push
jobs: ios_build: name: Build iOS target_platform: ios steps: - name: Install dependencies run: flutter pub get - name: Build IPA run: flutter build ipa --release artifacts: - build/ios/ipa/*.ipa
macos_build: name: Build macOS target_platform: macos steps: - name: Install dependencies run: flutter pub get - name: Build macOS run: flutter build macos --release artifacts: - build/macos/Build/Products/Release/*.appBoth jobs run in parallel because neither declares needs:.
Collecting Flutter Build Artifacts
Section titled “Collecting Flutter Build Artifacts”You can collect build outputs from your Flutter builds:
name: Flutter Build with Artifactsplatform: flutter
environment: flutter: "3.24.0"
triggers: - push
steps: - name: Install dependencies run: flutter pub get
- name: Build iOS run: flutter build ios
- name: Build Android run: flutter build apk
artifacts: - build/ios/iphoneos/**/*.app - build/ios/archive/**/*.xcarchive - build/app/outputs/**/*.apk