Skip to main content

How to set up CI/CD on iOS flutter app

Step 1: Configure Xcode project settings​

  • Turn off Automatically manage signing => Assign with manual files (generated by fastlane match development and fastlane match appstore)
  • Change Bundle Identifier

Step 2: Setup firebase project​

Step 3: Setup Firebase​

  • Move GoogleService-Info.plist to ios/Runner

Step 4: Create app use fastlane produce​

fastlane produce
<!-- enter bundler id -->
<!-- enter app name (must unique on apple platform) -->

Step 5: Set up fastlane​

cd ios
fastlane init
# Select 4

Step 6: Update Appfile​

app_identifier("<input>") # The bundle identifier of your app
apple_id("<input>") # Your Apple Developer Portal username

itc_team_id("<input>") # App Store Connect Team ID
team_id("<input>") # Developer Portal Team ID

Step 7: Init certificate and plugin​

  • Below commands will create new files on branch master
note

You only have to do this once on your project

fastlane match init
PRIVATE_TOKEN="personal token in gitlab" fastlane match development
PRIVATE_TOKEN="personal token in gitlab" fastlane match appstore
PRIVATE_TOKEN="personal token in gitlab" fastlane match adhoc
  • Then, select gitlab_secure_files (option 4)
  • Gitlab Project: input your apple-certificates repository
  • Gitlab Host: input your host https://gitlab.example.com

Add plugins by

fastlane add_plugin firebase_app_distribution
fastlane add_plugin load_json

Then, add ios/.bundle/config

---
BUNDLE_PATH: "vendor/bundle"

Then, add android/.ruby-version

3.1.2

Step 8: Build​

flutter build ios

Step 9: Remove RunnerTests​

  • Remove RunnerTests in ios/Podfile

Step 10: Update Fastfile​

Step 11: Input Fastfile, copy AuthKey.p8 from Apple Connect API​

Step 12: Create groups.txt​

echo "oryza-testers" >> fastlane/groups.txt

Step 13: Create fastlane/Gymfile​

Final step: add CircleCIC​

tip

Remember to ignore Runner.app.dSYM.zip