build phase

A build phase defines tasks to be performed when building a target.

To view the build phases, open the project editor and click Build Phases. To add a build phases that doesn’t appear in the editor, click the Add button (+) and choose a build phase from the pop-up menu.

The different build phases are:

Phase

Description

Compile sources

Associates compilable source files such as Swift, Objective-C, Lex, and Yacc with the target and compiles them. Compiler flags can be specified for each source file, if necessary. This phase can be used once per target and is not supported by Aggregate and External Build Tool targets.

Copy bundle resources

Associates resources with the target, processes them, when appropriate, and copies them into the Resources subfolder within a product. This phase can be used once per target and only when the target’s product supports embedded resources.

Copy files

Associates project files and products of other targets with the target, code signs them if necessary, and copies them to a specified destination, typically a subfolder within a product. This build phase can be enabled for all builds or only during an installation build. This phase may be used multiple times per target.

Headers

Associates public, private, or project header files with the target. Public and private headers define API intended for use by other clients, and are copied into a product for installation. For example, public and private headers in a framework target are copied into Headers and PrivateHeaders subfolders within a product. Project headers define API used and built by a target, but not copied into a product. This phase can be used once per target.

Link binary with libraries

Associates libraries such as Apple frameworks with the target. These can be platform libraries, libraries produced by other targets, or external prebuilt XCFrameworks and libraries. Libraries can be designated as required or optional (weakly linked—that is, linked such that your app still loads even if the library isn’t present). This phase can be used once per target and is not supported by Aggregate and External Build Tool targets.

If you use Mac Catalyst to build a Mac version of an iPad app, you can choose the platform for the framework or library.

Run script

Runs a specified shell script during the build process. This script can reference build settings from the target, such as $(SRCROOT), the directory containing the target’s source files. This build phase also lets you provide a list of input and output files. The script always runs when no input and output files are provided. When input and output files are provided, the script only runs if it has never been run before, one of the input files has changed, or one of the output files is missing. This build phase can be enabled for all builds or only during an installation build, and may be added multiple times per target.

Target dependencies

Explicitly specifies other targets, in the same project (not in the same workspace) or a linked project, that must be built before the target itself can build. For example, targets that depend on another framework in the project are usually configured with a target dependency for that framework. Xcode implicitly infers some dependencies, but this build phase provides greater control over dependencies and their build order.