Codemagic Configuration
Complete guide for setting up and managing Codemagic CI/CD for Remind Tools.
Overview
Codemagic handles:
- iOS builds and TestFlight deployment
- Android builds and Play Store deployment
- Web builds and hosting
- Desktop builds (macOS, Windows, Linux)
Configuration
codemagic.yaml
workflows:
production:
name: Production Build
max_build_duration: 60
environment:
flutter: 3.19.0
xcode: latest
cocoapods: default
groups:
- production_credentials
vars:
APP_STORE_CONNECT_KEY_IDENTIFIER: $APP_STORE_KEY_ID
APP_STORE_CONNECT_ISSUER_ID: $APP_STORE_ISSUER_ID
BUNDLE_ID: "tools.remind.trips"
triggering:
events:
- tag
tag_patterns:
- pattern: 'v*'
include: true
scripts:
- name: Install dependencies
script: |
melos bootstrap
- name: Run tests
script: |
melos test
- name: Build iOS
script: |
cd apps/trips_app
flutter build ipa --release
- name: Build Android
script: |
cd apps/trips_app
flutter build appbundle --release
artifacts:
- build/ios/ipa/*.ipa
- build/app/outputs/bundle/release/*.aab
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
google_play:
credentials: $GOOGLE_PLAY_CREDENTIALS
track: internal
Environment Variables
Required Secrets
APP_STORE_CONNECT_PRIVATE_KEY
APP_STORE_CONNECT_KEY_IDENTIFIER
APP_STORE_CONNECT_ISSUER_ID
CERTIFICATE_PRIVATE_KEY
PROVISIONING_PROFILE
GOOGLE_PLAY_CREDENTIALS
ANDROID_KEYSTORE
ANDROID_KEYSTORE_PASSWORD
ANDROID_KEY_ALIAS
ANDROID_KEY_PASSWORD
SUPABASE_URL
SUPABASE_ANON_KEY
MAPBOX_ACCESS_TOKEN
GEMINI_API_KEY
SENTRY_DSN
Build Workflows
Production Workflow
Trigger
Push tag matching v* pattern
Environment Setup
Configure Flutter, Xcode, and dependencies
Testing
Run full test suite
Build
Create release builds for all platforms
Sign
Code sign iOS and Android builds
Staging Workflow
staging:
name: Staging Build
triggering:
events:
- push
branch_patterns:
- pattern: 'develop'
scripts:
- name: Build with staging config
script: |
flutter build apk \
--dart-define=ENVIRONMENT=staging
iOS Setup
Codemagic automatically manages certificates and provisioning profiles.
Automatic Code Signing
ios_signing:
distribution_type: app_store
bundle_identifier: tools.remind.trips
Manual Code Signing
scripts:
- name: Set up code signing
script: |
keychain initialize
app-store-connect fetch-signing-files \
"$BUNDLE_ID" \
--type IOS_APP_STORE \
--create
keychain add-certificates
xcode-project use-profiles
Android Setup
Keystore Configuration
scripts:
- name: Set up keystore
script: |
echo $ANDROID_KEYSTORE | base64 --decode > keystore.jks
cat >> "$CM_BUILD_DIR/android/key.properties" <<EOF
storePassword=$ANDROID_KEYSTORE_PASSWORD
keyPassword=$ANDROID_KEY_PASSWORD
keyAlias=$ANDROID_KEY_ALIAS
storeFile=$CM_BUILD_DIR/keystore.jks
EOF
Web Deployment
web_publishing:
firebase_hosting:
project_id: remind-tools
site: trips-app
token: $FIREBASE_TOKEN
Build Optimization
Caching
cache:
cache_paths:
- $HOME/.pub-cache
- $HOME/Library/Caches/CocoaPods
- $FLUTTER_ROOT/.pub-cache
Parallel Builds
workflows:
parallel_builds:
scripts:
- name: Build apps in parallel
script: |
(
cd apps/trips_app && flutter build apk &
cd apps/money_app && flutter build apk &
wait
)
Monitoring
Build Notifications
Email
Automatic on failure
Slack
publishing:
slack:
channel: '#builds'
notify_on_build_start: true
Build Metrics
- Average build time: ~15 minutes
- Success rate: 95%+
- Cost per build: $0.50
Troubleshooting
| Issue | Solution |
|---|
| iOS signing failed | Regenerate certificates |
| Android build failed | Check keystore validity |
| Timeout | Increase max_build_duration |
| Out of memory | Use larger instance |
Best Practices
- Use build groups for environment variables
- Cache dependencies to speed up builds
- Run tests early to fail fast
- Use webhooks for deployment tracking
- Monitor build times and optimize
- Keep artifacts for debugging