TExcelTAD
Home › Mobile Build Pipelines: Gradle/AGP, Xcode, SwiftPM & Fastlane › Mobile Build Pipelines: The Big Picture

Mobile Build Pipelines: The Big Picture

A desktop or server build usually ends with a binary or a container image. A mobile build ends somewhere stricter: a store. Google Play and the App Store only accept packages that are signed with the right key, carry a version number higher than the last upload, target a recent enough OS API level and come in the format the store expects. Everything in this course is about getting from source code to that package reproducibly, on a CI machine, without a human clicking in an IDE.

Who this course is for

You know how Gradle works in general: tasks, the Kotlin DSL, plugins, the wrapper, caches. If not, start with Java Builds: Maven & Gradle. You've written a little Kotlin or Java for Android, or Swift for iOS (the Kotlin course's Android lesson and the Swift course are enough). Flutter developers will recognise all of it: flutter build appbundle and flutter build ipa drive exactly the Gradle and Xcode builds taught here (see Flutter's Build & Deploy lesson).

Two platforms, one shape

Both platforms follow the same pipeline. Only the tools change:

Step Android iOS
Describe the build settings.gradle.kts, build.gradle.kts, the android {} block .xcodeproj / .xcworkspace, targets, schemes, .xcconfig files
Dependencies Gradle repositories (google(), mavenCentral()) Swift Package Manager (Package.swift, Package.resolved)
Variants build types × product flavors configurations × schemes
Compile javac/kotlinc → .class → D8/R8 → .dex swiftc/clang → machine code
Package APK or App Bundle (.aab) .app inside an .xcarchive, exported as .ipa
Sign a keystore (.jks) and signingConfigs a certificate + provisioning profile
Ship Play Console (Play Developer API, Fastlane supply) App Store Connect / TestFlight (API, Fastlane pilot)
Runs on any Linux, macOS or Windows machine macOS only (Xcode)

That last row shapes every CI setup: Android builds run in a Linux container, iOS builds need a Mac (a macOS runner, a Mac mini in a rack or Xcode Cloud).

A first look

Every bash session in this course is real. Here the Android Gradle Plugin (AGP) builds a debug APK from a four-file project. You'll take this project apart in Project Structure; for now just watch what comes out:

bash · try it yourself
mkdir -p hello/app/src/main/java/com/example/hello && cd hello
cat > settings.gradle.kts <<'KTS'
pluginManagement { repositories { google(); mavenCentral(); gradlePluginPortal() } }
dependencyResolutionManagement { repositories { google(); mavenCentral() } }
rootProject.name = "hello"
include(":app")
KTS
echo 'plugins { id("com.android.application") version "9.4.1" apply false }' > build.gradle.kts
cat > app/build.gradle.kts <<'KTS'
plugins { id("com.android.application") }

android {
    namespace = "com.example.hello"
    compileSdk = 36
    defaultConfig {
        applicationId = "com.example.hello"
        minSdk = 24
        targetSdk = 36
        versionCode = 1
        versionName = "1.0"
    }
}
KTS
cat > app/src/main/AndroidManifest.xml <<'XML'
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application android:label="Hello">
        <activity android:name=".MainActivity" android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>
XML
cat > app/src/main/java/com/example/hello/MainActivity.java <<'JAVA'
package com.example.hello;

public class MainActivity extends android.app.Activity {
    @Override protected void onCreate(android.os.Bundle state) {
        super.onCreate(state);
        android.widget.TextView view = new android.widget.TextView(this);
        view.setText("Hello");
        setContentView(view);
    }
}
JAVA
gradle wrapper > /dev/null
./gradlew assembleDebug | grep -E '^BUILD|actionable'
find app/build/outputs -type f | sort
BUILD SUCCESSFUL in 13s
33 actionable tasks: 33 executed
app/build/outputs/apk/debug/app-debug.apk
app/build/outputs/apk/debug/output-metadata.json
app/build/outputs/logs/manifest-merger-debug-report.txt

Thirty-three tasks for a one-class app: resource compilation (aapt2), Java compilation, dexing (D8), the manifest merger, packaging and debug signing. The rest of the Android part of the course opens these tasks one by one.

How the sessions run

The sessions were recorded in a Linux container without network access that holds:

Tool Version
JDK Eclipse Temurin 21
Gradle 9.8.2 (the wrapper's distribution is pre-installed)
Android Gradle Plugin 9.4.1, with everything it downloads for a Java app cached
Android SDK platform android-36, build-tools 36.0.0 (aapt2, apksigner, zipalign, d8), command-line tools (apkanalyzer, retrace)
bundletool 1.18.3
Keystores a demo release keystore ~/release.jks and the usual ~/.android/debug.keystore

Some honest limits follow from "offline": no AndroidX, Kotlin Android libraries, Compose or Android Lint (their artifacts aren't cached), so the apps are plain Java with android.app.Activity. There is no emulator, so we inspect packages instead of launching them. Xcode only runs on macOS, so the Apple and Fastlane lessons show non-run files and commands, checked against Apple's and Fastlane's documentation, paired with runnable Python models of the ideas.

Gradle in the container runs with one worker (org.gradle.workers.max=1) and a plain console, so task order is stable. Durations like in 13s change from run to run; everything else is exact.

A runnable model of the pipeline

Here is the pipeline as data. Each stage consumes the previous stage's output; a release build adds shrinking and real signing. Edit the lists to see where a step would land:

python · try it yourself
android = [
    ("resources", "aapt2 compile + link", "res/ -> resources.arsc, R.java"),
    ("compile",   "javac / kotlinc",       ".java/.kt -> .class"),
    ("shrink",    "R8 (release only)",     ".class -> fewer, smaller .class"),
    ("dex",       "D8 / R8",               ".class -> classes.dex"),
    ("package",   "AGP packager",          "dex + resources + manifest -> .apk / .aab"),
    ("sign",      "apksig (signingConfig)", ".apk -> signed .apk"),
]
ios = [
    ("resources", "actool / ibtool",       "assets, storyboards -> compiled"),
    ("compile",   "swiftc / clang",        ".swift/.m -> .o"),
    ("link",      "ld",                    ".o -> executable"),
    ("package",   "xcodebuild archive",    ".app -> .xcarchive"),
    ("sign",      "codesign",              "certificate + provisioning profile"),
    ("export",    "xcodebuild -exportArchive", ".xcarchive -> .ipa"),
]

def show(name, stages, release):
    print(f"{name} ({'release' if release else 'debug'}):")
    for step, tool, what in stages:
        if step == "shrink" and not release:
            continue
        print(f"  {step:<9} {tool:<26} {what}")

show("Android", android, release=False)
show("Android", android, release=True)
show("iOS", ios, release=True)
Android (debug):
  resources aapt2 compile + link       res/ -> resources.arsc, R.java
  compile   javac / kotlinc            .java/.kt -> .class
  dex       D8 / R8                    .class -> classes.dex
  package   AGP packager               dex + resources + manifest -> .apk / .aab
  sign      apksig (signingConfig)     .apk -> signed .apk
Android (release):
  resources aapt2 compile + link       res/ -> resources.arsc, R.java
  compile   javac / kotlinc            .java/.kt -> .class
  shrink    R8 (release only)          .class -> fewer, smaller .class
  dex       D8 / R8                    .class -> classes.dex
  package   AGP packager               dex + resources + manifest -> .apk / .aab
  sign      apksig (signingConfig)     .apk -> signed .apk
iOS (release):
  resources actool / ibtool            assets, storyboards -> compiled
  compile   swiftc / clang             .swift/.m -> .o
  link      ld                         .o -> executable
  package   xcodebuild archive         .app -> .xcarchive
  sign      codesign                   certificate + provisioning profile
  export    xcodebuild -exportArchive  .xcarchive -> .ipa

What you'll build

The course ends with a Mini Project: a CI-ready Android release with two flavors, R8, a signed APK and an App Bundle whose outputs are verified with apksigner and bundletool, followed by the iOS equivalent as an xcodebuild + Fastlane lane.

Test yourself

Why do iOS builds need different CI machines from Android builds?

  1. iOS apps are larger
  2. Xcode and its toolchain only run on macOS
  3. Android builds need a GPU
  4. App Store Connect blocks Linux IP addresses

Which Android tool turns Java/Kotlin bytecode into the .dex format the device runs?

  1. aapt2
  2. D8 (or R8 in release builds)
  3. zipalign
  4. bundletool

What does the Android signing step correspond to on iOS?

  1. Package.resolved
  2. codesign with a certificate and a provisioning profile
  3. the scheme
  4. TestFlight