TExcelTAD
Home › Mobile Build Pipelines: Gradle/AGP, Xcode, SwiftPM & Fastlane › The Xcode Build System: Targets, Schemes & Configurations

The Xcode Build System: Targets, Schemes & Configurations

The Apple side of mobile builds has the same shape as Android's, under different names. Where Gradle has modules, build types and flavors, Xcode has targets, configurations and schemes, stored in a project file that is mostly edited through Xcode's UI and built on the command line with xcodebuild.

Note: Xcode only runs on macOS, so every Apple example in this course is non-run: project files, commands and their typical output, checked against Apple's documentation. The runnable examples are Python models of the ideas. Build-system behaviour you can try yourself on any Mac with Xcode installed.

The vocabulary, mapped to Android

Xcode What it is Closest Android/Gradle idea
Workspace (.xcworkspace) a container of projects (and Swift packages) built together the Gradle root build
Project (.xcodeproj) targets, build settings, file references (project.pbxproj inside) a set of modules
Target one product: an app, a framework, a test bundle, an extension a module (:app, :core)
Product what a target produces: Hello.app, Core.framework, HelloTests.xctest an APK / AAR
Build configuration a named set of build settings: Debug, Release by default a build type
Build setting one key, e.g. SWIFT_OPTIMIZATION_LEVEL, PRODUCT_BUNDLE_IDENTIFIER a property in the android {} block
Scheme which targets to build, test, run, profile, analyse and archive, and with which configuration for each a set of Gradle tasks + a variant
Destination what to build for: a simulator, a device, "any iOS device" an ABI / device spec

There are no product flavors. Teams model "free vs paid" or white-label apps as several targets sharing sources, as extra configurations (Debug-Staging, Release-Staging), or as several schemes pointing at different configurations.

A typical project

text
Hello.xcworkspace
├── Hello.xcodeproj
│   ├── project.pbxproj             targets, settings, file references (merge-conflict magnet)
│   └── xcshareddata/xcschemes/
│       └── Hello.xcscheme          a SHARED scheme: commit it, or CI can't see it
├── Hello/                          app sources, Assets.xcassets, Info.plist
├── HelloTests/                     unit tests (XCTest or Swift Testing)
├── Configs/                        Base.xcconfig, Debug.xcconfig, Release.xcconfig
└── Packages/Core/Package.swift     a local Swift package

Shared schemes. Schemes are per-user (in xcuserdata/, which you ignore) unless you tick Shared; then they live in xcshareddata/ and get committed. A CI job that fails with "The project does not contain a scheme named Hello" almost always means the scheme isn't shared.

Schemes and actions

A scheme has six actions, each with its own build configuration:

Action Default configuration xcodebuild
Build (per action below) build
Run Debug (Xcode only)
Test Debug test
Profile Release (Instruments)
Analyze Debug analyze
Archive Release archive

The Archive action is the release build: it builds with the Release configuration, for a generic device, and produces an .xcarchive. You'll run it in xcodebuild: Build, Test, Archive & Export.

Targets, dependencies and the build graph

A scheme's build list names targets; Xcode adds every target they depend on (explicit target dependencies, linked frameworks, Swift package products) and builds them in dependency order, in parallel where it can. Since Xcode 10 this is the "new build system" (written in Swift as swift-build, open-sourced in 2025), which plans the whole workspace as one task graph, much like Gradle. A model of the ordering:

python · try it yourself
from graphlib import TopologicalSorter

targets = {
    "Hello":          ["Core", "Analytics", "WidgetExtension"],   # the app embeds an extension
    "WidgetExtension": ["Core"],
    "Analytics":       ["Core"],
    "Core":            [],
    "HelloTests":      ["Hello"],                                 # test bundle hosted by the app
}

def build_order(scheme_targets):
    needed, stack = set(), list(scheme_targets)
    while stack:                                   # everything reachable from the scheme
        t = stack.pop()
        if t not in needed:
            needed.add(t)
            stack.extend(targets[t])
    graph = {t: [d for d in targets[t] if d in needed] for t in needed}
    ts = TopologicalSorter(graph)
    ts.prepare()
    wave = 1
    while ts.is_active():
        ready = sorted(ts.get_ready())
        print(f"  wave {wave}: {', '.join(ready)}")
        ts.done(*ready)
        wave += 1

print("scheme Hello, action Build:")
build_order(["Hello"])
print("scheme Hello, action Test:")
build_order(["Hello", "HelloTests"])
scheme Hello, action Build:
  wave 1: Core
  wave 2: Analytics, WidgetExtension
  wave 3: Hello
scheme Hello, action Test:
  wave 1: Core
  wave 2: Analytics, WidgetExtension
  wave 3: Hello
  wave 4: HelloTests

Targets in the same wave can build in parallel. The real build system goes further and parallelises inside targets (compiling a target's Swift files while its dependency is still linking), but the dependency rule is the same.

Configurations and build settings

Every target has a value for each build setting in each configuration. Settings come from up to five layers (target, target xcconfig, project, project xcconfig, platform defaults), which is why a setting "set in Xcode" sometimes seems ignored: a more specific layer overrides it. The next lesson, xcconfig Files & Build Settings, moves those settings out of project.pbxproj into text files you can review. Useful ones to know:

Build setting Meaning
PRODUCT_BUNDLE_IDENTIFIER the app's identity (like applicationId)
MARKETING_VERSION / CURRENT_PROJECT_VERSION version shown to users / build number (versionName / versionCode)
IPHONEOS_DEPLOYMENT_TARGET oldest iOS that can install the app (minSdk)
SDKROOT which SDK to build against (iphoneos, macosx)
SWIFT_OPTIMIZATION_LEVEL -Onone (Debug) or -O (Release)
SWIFT_ACTIVE_COMPILATION_CONDITIONS flags for #if DEBUG / #if STAGING
CODE_SIGN_STYLE, DEVELOPMENT_TEAM, CODE_SIGN_IDENTITY, PROVISIONING_PROFILE_SPECIFIER signing (Code Signing & Provisioning)
DEBUG_INFORMATION_FORMAT dwarf-with-dsym in Release, so crash reports can be symbolicated
ENABLE_USER_SCRIPT_SANDBOXING sandboxes Run Script build phases (on by default in new projects)

Test yourself

Which Xcode concept decides which targets are built and with which configuration for testing and archiving?

  1. The target
  2. The scheme
  3. The workspace
  4. The xcconfig file

CI fails with "The project does not contain a scheme named Hello", but it works in Xcode. Most likely cause?

  1. The scheme isn't shared, so it lives in xcuserdata and wasn't committed
  2. CI uses an older Swift
  3. The keystore is missing
  4. The scheme name is case-insensitive

Xcode has no product flavors. How do teams usually build free and paid editions?

  1. They can't
  2. Separate targets sharing sources, or extra configurations and schemes
  3. Swift packages only
  4. Two repositories