Skip to main content

Scheme

A custom scheme for a project that defines how to build, run, test, profile, analyze, and archive.

Overview

A Scheme defines a collection of targets to build, run, test, profile, analyze, and archive. Schemes control the behavior of these actions in Xcode and from the command line.

Usage

Minimal Example

Initializer

.scheme() Static Method

String
required
The name of the scheme.
Bool
default:"true"
Marks the scheme as shared (i.e., checked into the repository and visible to xcodebuild from the command line).
Bool
default:"false"
When true, the scheme doesn’t show up in Xcode’s scheme dropdown list.
BuildAction?
default:"nil"
Action that builds the project targets.
TestAction?
default:"nil"
Action that runs the project tests.
RunAction?
default:"nil"
Action that runs project built products.
ArchiveAction?
default:"nil"
Action that runs the project archive.
ProfileAction?
default:"nil"
Action that profiles the project.
AnalyzeAction?
default:"nil"
Action that analyzes the project.

Action Types

BuildAction

Defines which targets to build and in what order.

TestAction

Defines which test targets to run and testing options.

RunAction

Defines how to run the app, including which executable to run and runtime options.

ArchiveAction

Defines how to archive the app for distribution.

ProfileAction

Defines how to profile the app using Instruments.

AnalyzeAction

Defines how to run static analysis.

Best Practices

  1. Shared Schemes: Set shared: true for schemes you want to commit to version control and use in CI/CD.
  2. Configuration-Specific Schemes: Create separate schemes for different configurations:
  3. Test Coverage: Enable code coverage in test actions:
  4. Hidden Schemes: Use hidden: true for internal or experimental schemes you don’t want to clutter the UI.
  • Project - Contains schemes
  • Target - Referenced by scheme actions
  • Settings - Configurations referenced by actions