XCODEBUILD(1) General Commands Manual XCODEBUILD(1)

xcodebuildbuild Xcode projects and workspaces

xcodebuild [-project name.xcodeproj] [[-target targetname] ... | -alltargets] [-configuration configurationname] [-sdk [sdkfullpath | sdkname]] [action ...] [buildsetting=value ...] [-userdefault=value ...]


xcodebuild [-project name.xcodeproj] -scheme schemename [[-destination destinationspecifier] ...] [-destination-timeout value] [-configuration configurationname] [-sdk [sdkfullpath | sdkname]] [action ...] [buildsetting=value ...] [-userdefault=value ...]


xcodebuild -workspace name.xcworkspace -scheme schemename [[-destination destinationspecifier] ...] [-destination-timeout value] [-configuration configurationname] [-sdk [sdkfullpath | sdkname]] [action ...] [buildsetting=value ...] [-userdefault=value ...]


xcodebuild -version [-sdk [sdkfullpath | sdkname]] [infoitem]


xcodebuild -showsdks


xcodebuild -showBuildSettings [-project name.xcodeproj | [-workspace name.xcworkspace -scheme schemename]]


xcodebuild -showdestinations [-project name.xcodeproj | [-workspace name.xcworkspace -scheme schemename]]


xcodebuild -showTestPlans [-project name.xcodeproj | -workspace name.xcworkspace] -scheme schemename


xcodebuild -list [-project name.xcodeproj | -workspace name.xcworkspace]


xcodebuild -exportArchive -archivePath xcarchivepath -exportPath destinationpath -exportOptionsPlist path

xcodebuild -exportNotarizedApp -archivePath xcarchivepath -exportPath destinationpath


xcodebuild -exportLocalizations -project name.xcodeproj -localizationPath path [[-exportLanguage language] ...]

xcodebuild -importLocalizations -project name.xcodeproj -localizationPath path

xcodebuild builds one or more targets contained in an Xcode project, or builds a scheme contained in an Xcode workspace or Xcode project.

To build an Xcode project, run xcodebuild from the directory containing your project (i.e. the directory containing the name.xcodeproj package). If you have multiple projects in the this directory you will need to use -project to indicate which project should be built. By default, xcodebuild builds the first target listed in the project, with the default build configuration. The order of the targets is a property of the project and is the same for all users of the project.

To build an Xcode workspace, you must pass both the -workspace and -scheme options to define the build. The parameters of the scheme will control which targets are built and how they are built, although you may pass other options to xcodebuild to override some parameters of the scheme.

There are also several options that display info about the installed version of Xcode or about projects or workspaces in the local directory, but which do not initiate an action. These include -list, -showBuildSettings, -showdestinations, -showsdks, -showTestPlans, -usage, and -version.

name.xcodeproj
Build the project name.xcodeproj. Required if there are multiple project files in the same directory.
targetname
Build the target specified by targetname.
Build all the targets in the specified project.
name.xcworkspace
Build the workspace name.xcworkspace.
schemename
Build the scheme specified by schemename. Required if building a workspace.
destinationspecifier
Use the destination device described by destinationspecifier. Defaults to a destination that is compatible with the selected scheme. See the Destinations section below for more details.
timeout
Use the specified timeout when searching for a destination device. The default is 30 seconds.
configurationname
Use the build configuration specified by configurationname when building each target.
architecture
Use the architecture specified by architecture when building each target.
[sdkfullpath | sdkname]
Build an Xcode project or workspace against the specified SDK, using build tools appropriate for that SDK. The argument may be an absolute path to an SDK, or the canonical name of an SDK.
Lists all available SDKs that Xcode knows about, including their canonical names suitable for use with -sdk. Does not initiate a build.
Lists the build settings for targets in a project or workspace. Does not initiate a build. Use with -target or with -scheme. With -scheme, optionally pass a build action (such as build or test) to use targets from the matching scheme action.
Lists the valid destinations for a project or workspace and scheme. Does not initiate a build. Use with -project or -workspace and -scheme.
Display a report of the timings of all the commands invoked during the build.
Lists the test plans (if any) associated with the specified scheme. Does not initiate a build. Use with -scheme.
Lists the targets and configurations in a project, or the schemes in a workspace. Does not initiate a build. Use with -project or -workspace.
[YES | NO]
Turns the address sanitizer on or off. This overrides the setting for the launch action of a scheme in a workspace.
[YES | NO]
Turns the thread sanitizer on or off. This overrides the setting for the launch action of a scheme in a workspace.
[YES | NO]
Turns the undefined behavior sanitizer on or off. This overrides the setting for the launch action of a scheme in a workspace.
[YES | NO]
Turns code coverage on or off during testing. This overrides the setting for the test action of a scheme in a workspace.
language
Specifies ISO 639-1 language during testing. This overrides the setting for the test action of a scheme in a workspace.
region
Specifies ISO 3166-1 region during testing. This overrides the setting for the test action of a scheme in a workspace.
path
Overrides the folder that should be used for derived data when performing an action on a scheme in a workspace.
path
Writes a bundle to the specified path with results from performing an action on a scheme in a workspace. If the path already exists, xcodebuild will exit with an error. Intermediate directories will be created automatically. The bundle contains build logs, code coverage reports, XML property lists with test results, screenshots and other attachments collected during testing, and various diagnostic logs.
Allow xcodebuild to communicate with the Apple Developer website. For automatically signed targets, xcodebuild will create and update profiles, app IDs, and certificates. For manually signed targets, xcodebuild will download missing or updated provisioning profiles. Requires a developer account to have been added in Xcode's Accounts preference pane.
Allow xcodebuild to register your destination device on the Apple Developer website if necessary. Requires -allowProvisioningUpdates.
Specifies the path to an authentication key issued by App Store Connect. If specified, xcodebuild will authenticate with the Apple Developer website using this credential. Requires -authenticationKeyID and -authenticationKeyIssuerID.
Specifies the key identifier associated with the App Store Conect authentication key at -authenticationKeyPath. This string can be located in the users and access details for your provider at
⟨URL: https://appstoreconnect.apple.com ⟩
Specifies the App Store Connect issuer identifier associated with the authentication key at -authenticationKeyPath. This string can be located in the users and access details for your provider at
⟨URL: https://appstoreconnect.apple.com ⟩
Specifies that an archive should be distributed. Requires -archivePath and -exportOptionsPlist. For exporting, -exportPath is also required. Cannot be passed along with an action.
Export an archive that has been notarized by Apple. Requires -archivePath and -exportPath.
xcarchivepath
Specifies the path for the archive produced by the archive action, or specifies the archive that should be exported when -exportArchive or -exportNotarizedApp is passed.
destinationpath
Specifies the destination for the exported product, including the name of the exported file.
path
Specifies options for -exportArchive. xcodebuild -help can print the full set of available options.
Exports localizations to XLIFF files. Requires -project and -localizationPath. Cannot be passed along with an action.
Imports localizations from an XLIFF file. Requires -project and -localizationPath. Cannot be passed along with an action.
Specifies a path to a directory or a single XLIFF localization file.
language
Specifies optional ISO 639-1 languages included in a localization export. May be repeated to specify multiple languages. May be excluded to specify an export includes only development language strings.
action ...
Specify one or more actions to perform. Available actions are:
Build the target in the build root (SYMROOT). This is the default action, and is used if no action is given.
Build the target and associated tests in the build root (SYMROOT). This will also produce an xctestrun file in the build root. This requires specifying a scheme.
Build and analyze a target or scheme from the build root (SYMROOT). This requires specifying a scheme.
Archive a scheme from the build root (SYMROOT). This requires specifying a scheme.
Test a scheme from the build root (SYMROOT). This requires specifying a scheme and optionally a destination.
Test compiled bundles. If a scheme is provided with -scheme then the command finds bundles in the build root (SRCROOT). If an xctestrun file is provided with -xctestrun then the command finds bundles at paths specified in the xctestrun file.
Build the target and associated documentation in the build root (SRCROOT).
Copy the source of the project to the source root (SRCROOT).
Build the target and install it into the target's installation directory in the distribution root (DSTROOT).
Remove build products and intermediate files from the build root (SYMROOT).
filename
Load the build settings defined in filename when building all targets. These settings will override all other settings, including settings passed individually on the command line.
path-to-xctestproducts
Specifies xctestproducts path. XCTestProducts are a unified test product format for XCTest. Can only be used with build-for-testing or test-without-building action. Cannot be used with -workspace or -project. When used with build-for-testing the path will be used as the destination for where the xctestproducts archive is written to. Example path: MyProject_MyScheme.xctestproducts When used with test-without-building the path will be used as the source of which xctestproducts archive to use for testing. test-without-building -testProductsPath Cannot be used with -workspace or -project.
xctestrunpath
Specifies test run parameters. Can only be used with the test-without-building action. Cannot be used with -workspace or -project. See
⟨URL: x-man-page://5/xcodebuild.xctestrun ⟩ for file format details.
test-plan-name
Specifies which test plan associated with the scheme should be used for testing. Pass the name of the .xctestplan file without its extension.
test-identifier, -only-testing test-identifier
Constrain test targets, classes, or methods in test actions. -only-testing constrains a test action to only testing a specified identifier, and excluding all other identifiers. -skip-testing constrains a test action to skip testing a specified identifier, but including all other identifiers. Test identifiers have the form TestTarget[/TestClass[/TestMethod]]. The TestTarget component of an identifier is the name of a unit or UI testing bundle as shown in the Test Navigator. An xcodebuild command can combine multiple constraint options, but -only-testing has precedence over -skip-testing.
test-configuration-name, -only-test-configuration test-configuration-name
Constrain test configurations in test actions. -only-test-configuration constrains a test action to only test a specified test configuration within a test plan, and exclude all other test configurations. -skip-test-configuration constrains a test action to skip a specified test configuration, but include all other test configurations. Each test configuration name must match the name of a configuration specified in a test plan and is case-sensitive. An xcodebuild command can combine multiple constraint options, but -only-test-configuration has precedence over -skip-test-configuration.
Do not run tests on the specified destinations concurrently. The full test suite will run to completion on a given destination before it begins on the next.
number
If multiple device destinations are specified (and -disable-concurrent-destination-testing is not passed), only test on number devices at a time. For example, if four iOS devices are specified, but number is 2, the full test suite will run on each device, but only two devices will be testing at a given time.
number
If multiple simulator destinations are specified (and -disable-concurrent-destination-testing is not passed), only test on number simulators at a time. For example, if four iOS simulators are specified, but number is 2, the full test suite will run on each simulator, but only two simulators will be testing at a given time.
[YES | NO]
Overrides the per-target setting in the scheme for running tests in parallel.
number
Spawn exactly number test runners when executing tests in parallel. Overrides -maximum-parallel-testing-workers, if it is specified.
number
Limit the number of test runners that will be spawned when running tests in parallel to number.
If parallel testing is enabled (either via the -parallel-testing-enabled option, or on an individual test-target basis) and multiple destination specifiers are passed, distribute test classes among the destinations, instead of running the entire test suite on each destination (which is the default behavior when multiple destination specifiers are passed).
[YES | NO]
Enable or disable test timeout behavior. This value takes precedence over the value specified in the test plan.
seconds
The default execution time an individual test is given to execute, if test timeouts are enabled.
seconds
The maximum execution time an individual test is given to execute, regardless of the test's preferred allowance.
number
If specified, tests will run number times. May be used in conjunction with either -retry-tests-on-failure or -run-tests-until-failure, in which case this will become the maximum number of iterations.
If specified, tests will retry on failure. May be used in conjunction with -test-iterations number, in which case number will be the maximum number of iterations. Otherwise, a maximum of 3 is assumed. May not be used with -run-tests-until-failure.
If specified, tests will run until they fail. May be used in conjunction with -test-iterations number, in which case number will be the maximum number of iterations. Otherwise, a maximum of 100 is assumed. May not be used with -retry-tests-on-failure.
[YES | NO]
Whether or not each repetition of test should use a new process for its execution. Must be used in conjunction with -test-iterations, -retry-tests-on-failure, or -run-tests-until-failure. If not specified, tests will repeat in the same process.
[on-failure | never]
Whether or not verbose and long-running diagnostics, like sysdiagnoses or log archives, are collected when testing. If not specified, the value in the test plan will be used.
If specified alongside either the test or test-without-building actions, the set of tests that would normally execute will instead be listed/enumerated, and the list of tests will be output to either stdout (the default), or to a file whose location is specified via the -test-enumeration-output-path option. The format of the list of tests is controlled via the -test-enumeration-style and -test-enumeration-format options. Note that a -destination specifier must be supplied in order to enumerate the tests.
[hierarchical | flat]
Whether tests should be enumerated in a hierarchical organization (the default), meaning grouped by test plan, target, and class, or as a flat list of test identifiers that can subsequently be passed to the -skip-testing and -only-testing options.
[text | json]
Whether tests should be enumerated as human-readable text (the default), or as machine-parseable JSON.
[path | -]
Specifies a file path where the list of tests computed by the -enumerate-tests option will be written to disk. If - is supplied, the data will be written to stdout (which is also the default if this option is omitted).
-n
Print the commands that would be executed, but do not execute them.
Skip actions that cannot be performed instead of failing. This option is only honored if -scheme is passed.
buildsetting=value
Set the build setting buildsetting to value.

A detailed reference of Xcode build settings can be found at:
⟨URL: https://developer.apple.com/documentation/xcode/build-settings-reference ⟩

-userdefault=value
Set the user default userdefault to value.
[identifier | name]
Use a given toolchain, specified with either an identifier or name.
Do not print any output except for warnings and errors.
Provide additional status output.
Display version information for this install of Xcode. Does not initiate a build. When used in conjunction with -sdk, the version of the specified SDK is displayed, or all SDKs if -sdk is given no argument. Additionally, a single line of the reported version information may be returned if infoitem is specified.
Show the Xcode and SDK license agreements. Allows for accepting the license agreements without launching Xcode itself, which is useful for headless systems. Must be run as a privileged user.
Check if any additional system components or configuration tasks need to be performed. Exits with a non-zero code if additional system content needs to be installed, using -runFirstLaunch. Exits with 0 if system components are up-to-date.
Install additional system components and agree to the license.
Download and install all available platforms.
Displays usage information for xcodebuild.

The -destination option takes as its argument a destination specifier describing the device (or devices) to use as a destination. A destination specifier is a single argument consisting of a set of comma-separated key=value pairs. The -destination option may be specified multiple times to cause xcodebuild to perform the specified action on multiple destinations.

Destination specifiers may include the platform key to specify one of the supported destination platforms. There are additional keys which should be supplied depending on the platform of the device you are selecting.

Some devices may take time to look up. The -destination-timeout option can be used to specify the amount of time to wait before a device is considered unavailable. If unspecified, the default timeout is 30 seconds.

Currently, xcodebuild supports these platforms:

The local Mac, referred to in the Xcode interface as , and which supports the following keys:
arch
The architecture to use, e.g. arm64 or x86_64.
variant
The optional variant to use, e.g. Mac Catalyst or macOS.
An iOS device, which supports the following keys:
id
The identifier of the device to use, as shown in the Devices window. A valid destination specifier must provide either id or name, but not both.
name
The name of the device to use. A valid destination specifier must provide either id or name, but not both.
iOS Simulator
A simulated iOS device, which supports the following keys:
id
The identifier of the simulated device to use, as shown in the Devices window. A valid destination specifier must provide either id or name, but not both.
name
The name of the simulated device to use. A valid destination specifier must provide either id or name, but not both.
OS
When specifying the simulated device by name, the iOS version for that simulated device, such as 6.0, or the string latest (the default) to indicate the most recent version of iOS supported by this version of Xcode.
A watchOS app is always built and deployed nested inside of an iOS app. To use a watchOS device as your destination, specify a scheme which is configured to run a WatchKit app, and specify the iOS platform destination that is paired with the watchOS device you want to use.
watchOS Simulator
A watchOS Simulator app is always built and deployed nested inside of an iOS Simulator app. To use a watchOS Simulator device as your destination, specify a scheme which is configured to run a WatchKit app, and specify the iOS Simulator platform destination that is paired with the watchOS Simulator device you want to use.
A tvOS device, which supports the following keys:
id
The identifier of the device to use, as shown in the Devices window. A valid destination specifier must provide either id or name, but not both.
name
The name of the device to use. A valid destination specifier must provide either id or name, but not both.
tvOS Simulator
A simulated tvOS device, which supports the following keys:
id
The identifier of the simulated device to use, as shown in the Devices window. A valid destination specifier must provide either id or name, but not both.
name
The name of the simulated device to use. A valid destination specifier must provide either id or name, but not both.
OS
When specifying the simulated device by name, the tvOS version for that simulated device, such as 9.0, or the string latest (the default) to indicate the most recent version of tvOS supported by this version of Xcode.
The DriverKit environment, which supports the following key:
arch
The architecture to use, e.g. arm64 or x86_64.

Some actions (such as building) may be performed without an actual device present. To build against a platform generically instead of a specific device, the destination specifier may be prefixed with the optional string "generic/", indicating that the platform should be targeted generically. An example of a generic destination is the "Any iOS Device" destination displayed in Xcode's UI when no physical iOS device is present.

When more than one destination is specified with the -destination option, xcodebuild tests on those destinations concurrently. In this mode, xcodebuild automatically chooses the number of devices and simulators that are used simultaneously. All enabled tests in the scheme or xctestrun file are run on each destination.

The -exportArchive option specifies that xcodebuild should distribute the archive specified by -archivePath using the options specified by -exportOptionsPlist. xcodebuild -help can print the full set of available inputs to -exportOptionsPlist. The product can either be uploaded to Apple or exported locally. The exported product will be placed at the path specified by -exportPath.

Archives that have been uploaded to the Apple notary service can be distributed using the -exportNotarizedApp option. This specifies that xcodebuild should export a notarized app from the archive specified by -archivePath and place the exported product at the path specified by -exportPath. If the archive has not completed processing by the notary service, or processing failed, then xcodebuild will exit and emit informational or error messages.

When uploading an archive using the -exportArchive option, or exporting a notarized archive using the -exportNotarizedApp option, an Apple ID account belonging to the archive's development team is required. Enter the credentials for the Apple ID account using Xcode's Accounts preference pane before invoking xcodebuild.

The following environment variables affect the execution of xcodebuild:

Set to a path to a file, build settings in that file will be loaded and used when building all targets. These settings will override all other settings, including settings passed individually on the command line, and those in the file passed with the -xcconfig option.
Set an environment variable whose name is prefixed with to have that variable passed, with its prefix stripped, to all test runner processes launched during a test action. For example, sets the environment variable in the test runner's environment. Existing variables may be modified using the special token to represent their current value. For example, appends the string to any existing value of .

xcodebuild exits with codes defined by sysexits(3). It will exit with on success. On failure, it will commonly exit with if any options appear malformed, if any input files cannot be found, if any files cannot be read or written, and if the commands given to xcodebuild fail. It may exit with other codes in less common scenarios.

Cleans the build directory; then builds and installs the first target in the Xcode project in the directory from which xcodebuild was started.

Builds the targets and in the project using the configuration.

Builds the target in the Xcode project in the directory from which xcodebuild was started, putting intermediate files in the directory /Build/MyProj/Obj.root and the products of the build in the directory /Build/MyProj/Sym.root.

Builds the Xcode project in the directory from which xcodebuild was started against the macOS 10.6 SDK. The canonical names of all available SDKs can be viewed using the -showsdks option.

Builds the scheme MyScheme in the Xcode workspace MyWorkspace.xcworkspace.

Archives the scheme MyScheme in the Xcode workspace MyWorkspace.xcworkspace.

Build tests and associated targets in the scheme MyScheme in the Xcode workspace MyWorkspace.xcworkspace using the generic iOS device destination. The command also writes test parameters from the scheme to an xctestrun file in the built products directory.

Tests the scheme MyScheme in the Xcode workspace MyWorkspace.xcworkspace using both the iOS Simulator and the device named iPhone 5s for the latest version of iOS. The command assumes the test bundles are in the build root (SYMROOT). (Note that the shell requires arguments to be quoted or otherwise escaped if they contain spaces.)

Tests using both the iOS Simulator and the device named iPhone 5s. Test bundle paths and other test parameters are specified in MyTestRun.xctestrun. The command requires project binaries and does not require project source code.

Tests the scheme MyScheme in the Xcode workspace MyWorkspace.xcworkspace using the destination described as My Mac 64-bit in Xcode.

Tests the scheme MyScheme in the Xcode workspace MyWorkspace.xcworkspace using the destination described as My Mac 64-bit in Xcode. Only the test testFooWithBar of the test suite FooTests, part of the MyTests testing bundle target, will be run.

Exports the archive MyMobileApp.xcarchive to the path ExportDestination using the options specified in export.plist.

Exports two XLIFF files to MyDirectory from MyProject.xcodeproj containing development language strings and translations for Simplified Chinese and Mexican Spanish.

Export a single XLIFF file to MyDirectory from MyProject.xcodeproj containing only development language strings. (In this case, the -exportLanguage parameter has been excluded.)

Imports localizations from MyLocalizations.xliff into MyProject.xcodeproj. Translations with issues will be reported but not imported.

ibtool(1), sysexits(3), xcode-select(1), xcrun(1), xed(1)

Xcode Build Settings Reference ⟨URL: https://developer.apple.com/documentation/xcode/build-settings-reference ⟩

June 20, 2016 macOS