Xcode Cloud for Flutter Apps: Simplifying CI/CD

Virender Verma
4 min readFeb 11, 2025

--

Building and deploying iOS apps can be a time-consuming process, especially when working with Flutter applications. Manual builds, archiving, and publishing to TestFlight or the App Store can significantly slow down your development cycle. In this article, I’ll share my journey of implementing a CI/CD pipeline for Flutter apps using Xcode Cloud, and provide a step-by-step guide to help you streamline your deployment process.

The CI/CD Challenge

As a Flutter developer, I found myself spending considerable time on repetitive tasks: running build commands, archiving the app, and managing the publication process. These manual interventions were not just time-consuming but also prone to human error. I needed a reliable CI/CD pipeline to automate these processes and focus more on actual development.

The Fastlane Journey and Its Challenges

My first instinct was to use Fastlane, a popular automation tool for iOS and Android development. However, this path wasn’t as straightforward as expected:

  • Fastlane required an App Store Connect API key for integration
  • As a developer, I didn’t have the authorization to generate this key
  • The approval process involved multiple stakeholders
  • Waiting time for API key approval stretched to weeks

This situation left me in a limbo — unable to proceed with the automation while still dealing with time-consuming manual processes.

Discovering Xcode Cloud

While searching for alternatives, I came across Xcode Cloud — Apple’s native CI/CD solution. Unlike Fastlane, Xcode Cloud is seamlessly integrated into Xcode and does not require manual API key configurations. I decided to give it a shot and found the setup effortless due to the following advantages:

  • No API Key Hassles: Uses existing App Store Connect permissions linked to your Apple ID — no need for manually generated API keys.
  • Seamless Xcode Integration: No complex scripting — simply enable Xcode Cloud from Xcode and set up workflows via an intuitive UI.
  • Automatic App Store Submission: Deep integration with Apple’s ecosystem allows automatic uploads without external dependencies.

Setting Up Xcode Cloud for Your Flutter App

Step 1: Prepare Your Project

  1. Open your Flutter iOS project in Xcode.
  2. Create a folder named ci_scripts inside your project.
  3. Inside ci_scripts, create a new file named ci_post_clone.sh.

Step 2: Add the Build Script

Paste the following shell script into the ci_post_clone.sh file:

#!/bin/bash

# Navigate to the Flutter project directory
cd "$CI_PRIMARY_REPOSITORY_PATH"

# Install Flutter (if not already available in the environment)
if ! command -v flutter &> /dev/null
then
echo "Flutter is not installed. Installing Flutter SDK..."
git clone https://github.com/flutter/flutter.git --depth 1 -b stable $HOME/flutter
export PATH="$PATH:$HOME/flutter/bin"
else
echo "Flutter is already installed."
fi

# Verify Flutter installation
flutter --version

# Install dependencies
echo "Running Flutter pub get..."
# Install Flutter artifacts for iOS (--ios), or macOS (--macos) platforms.
flutter precache --ios

flutter pub get

echo "Installing cocoapods..."
# Install CocoaPods using Homebrew.
HOMEBREW_NO_AUTO_UPDATE=1 # disable homebrew's automatic updates.
brew install cocoapods

# Set up CocoaPods for iOS
echo "Running pod install for iOS..."
cd ios
pod install --repo-update

# Go back to the workspace root
cd "$CI_PRIMARY_REPOSITORY_PATH"

echo "Flutter Build running..."
flutter pub run build_runner build --delete-conflicting-outputs
flutter build ios --no-codesign -t lib/main.dart

Step 3: Configure Xcode Cloud Workflow

  1. Click IntegrateCreate Workflow.

2. In the Select a Product popup, select your app and click Next.

3. In the Review Workflow step, customize settings:

  • Choose when the workflow should run.
  • Select the required environment (e.g., OS version, Xcode version).
  • Configure actions and post-actions as needed.

4. Grant access to your source code. Once you’ve allowed Xcode Cloud to access your Git repository, Xcode confirms access. Click Next.

Step 4: Start Your First Build

Xcode Cloud combines Xcode, TestFlight, and App Store Connect into a powerful CI/CD system. Ensure your app has a record in App Store Connect, then start your first build.

Conclusion

Xcode Cloud has significantly streamlined my Flutter app deployment process. While Fastlane remains a powerful tool, Xcode Cloud’s native integration with Apple’s ecosystem makes it an excellent choice for teams already working within the Apple development environment. The setup process is straightforward, and the benefits of automated building and deployment quickly become apparent in your development workflow.

The elimination of manual API key configuration and the seamless integration with existing Apple services make Xcode Cloud an attractive option for Flutter developers looking to implement CI/CD pipelines for their iOS apps. As you begin implementing this solution, remember that proper configuration and understanding of the workflow are key to successful automation.

Remember to consult Apple’s documentation for the most up-to-date information about Xcode Cloud features and pricing, as these may change over time.

--

--

Virender Verma
Virender Verma

Responses (1)