Setting Up CodeMagic for Mobile App CI/CD
CodeMagic is a CI/CD service created specifically for mobile development. Unlike GitHub Actions or GitLab CI where you need to configure macOS agents, keychain, Xcode, Android SDK yourself, CodeMagic provides pre-configured macOS/Linux machines with tools already installed. For Flutter projects — especially convenient: officially supported by the Flutter team.
Two Configuration Formats
CodeMagic supports GUI configuration (Workflow Editor) and codemagic.yaml. For serious projects — only YAML: it's versioned in Git, changes reviewed via PR.
# codemagic.yaml
workflows:
android-release:
name: Android Release
max_build_duration: 60
environment:
groups:
- keystore_credentials
- google_play_credentials
vars:
PACKAGE_NAME: "com.myapp.android"
android_signing:
- keystore_reference
triggering:
events:
- push
branch_patterns:
- pattern: 'main'
scripts:
- name: Set build number
script: |
BUILD_NUMBER=$(($(google-play get-latest-build-number \
--package-name "$PACKAGE_NAME" \
--tracks=internal) + 1))
cd android && ./gradlew versionCode -PversionCode=$BUILD_NUMBER
- name: Build Android
script: |
cd android
./gradlew bundleRelease
artifacts:
- android/app/build/outputs/bundle/**/*.aab
publishing:
google_play:
credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS
track: internal
submit_as_draft: false
iOS Configuration
ios-release:
name: iOS Release
max_build_duration: 90
environment:
groups:
- appstore_credentials
ios_signing:
distribution_type: app_store
bundle_identifier: com.myapp.ios
scripts:
- name: Set build number
script: |
BUILD_NUMBER=$(app-store-connect get-latest-build-number \
--app-id $APP_STORE_APP_ID)
agvtool new-version -all $((BUILD_NUMBER + 1))
- name: Build iOS
script: |
xcode-project build-ipa \
--workspace "MyApp.xcworkspace" \
--scheme "MyApp"
artifacts:
- build/ios/ipa/*.ipa
publishing:
app_store_connect:
api_key: $APP_STORE_CONNECT_PRIVATE_KEY
key_id: $APP_STORE_CONNECT_KEY_IDENTIFIER
issuer_id: $APP_STORE_CONNECT_ISSUER_ID
submit_to_testflight: true
beta_groups:
- Internal Testers
Code Signing in CodeMagic
CodeMagic offers two paths for iOS signing:
Automatic code signing — CodeMagic creates a temporary certificate and provisioning profile via App Store Connect API. Doesn't require Fastlane Match. Convenient, but depends on CI user rights in App Store Connect.
Manual code signing — upload .p12 and .mobileprovision to CodeMagic Encrypted Variables. More reliable, full control.
Flutter in CodeMagic
flutter-multiplatform:
name: Flutter Release
environment:
flutter: stable
scripts:
- name: Get dependencies
script: flutter pub get
- name: Run tests
script: flutter test --coverage
- name: Build Android
script: |
flutter build appbundle \
--release \
--dart-define=ENV=production
- name: Build iOS
script: |
flutter build ipa \
--release \
--export-options-plist=/Users/builder/export_options.plist
Dependency Caching
cache:
cache_paths:
- $FLUTTER_ROOT/.pub-cache
- $HOME/.gradle/caches
- $HOME/Library/Caches/CocoaPods
Without caching, pod install and flutter pub get take 3–5 additional minutes per build.
Process
Register in CodeMagic → connect repository → write codemagic.yaml → configure signing (automatic or manual) → add environment groups with secrets → configure publishing → test run → write documentation.
Timeline: 2–3 days for one platform configuration, up to 5 days for iOS + Android + Flutter with publication to both stores. Cost is calculated individually.







