| XCODEBUILD(1) | General Commands Manual | XCODEBUILD(1) |
xcodebuild — build
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.
-project
name.xcodeproj-target
targetname-alltargets-workspace
name.xcworkspace-scheme
schemename-destination
destinationspecifier-destination-timeout
timeout-configuration
configurationname-arch
architecture-sdk
[sdkfullpath | sdkname]-showsdks-sdk. Does not
initiate a build.-showBuildSettings-target or with
-scheme. With -scheme,
optionally pass a build action (such as build or test) to use targets from
the matching scheme action.-showdestinations-project or
-workspace and
-scheme.-showBuildTimingSummary-showTestPlans-scheme.-list-project or
-workspace.-enableAddressSanitizer
[YES | NO]-enableThreadSanitizer
[YES | NO]-enableUndefinedBehaviorSanitizer
[YES | NO]-enableCodeCoverage
[YES | NO]-testLanguage
language-testRegion
region-derivedDataPath
path-resultBundlePath
path-allowProvisioningUpdates-allowProvisioningDeviceRegistration-allowProvisioningUpdates.-authenticationKeyPath-authenticationKeyID and
-authenticationKeyIssuerID.-authenticationKeyID-authenticationKeyPath. This
string can be located in the users and access details for your provider at
-authenticationKeyIssuerID-authenticationKeyPath. This
string can be located in the users and access details for your provider at
-exportArchive-archivePath and
-exportOptionsPlist. For exporting,
-exportPath is also required. Cannot be passed
along with an action.-exportNotarizedApp-archivePath and
-exportPath.-archivePath
xcarchivepatharchive action, or specifies the archive that
should be exported when -exportArchive or
-exportNotarizedApp is passed.-exportPath
destinationpath-exportOptionsPlist
path-exportArchive.
xcodebuild -help can print
the full set of available options.-exportLocalizations-importLocalizations-localizationPath-exportLanguage
languagebuildbuild-for-testinganalyzearchivetesttest-without-building-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.docbuildinstallsrcinstallclean-xcconfig
filename-testProductsPath
path-to-xctestproducts-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.-xctestrun
xctestrunpath-workspace or -project.
See
-testPlan
test-plan-name-skip-testing
test-identifier, -only-testing
test-identifier-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.-skip-test-configuration
test-configuration-name,
-only-test-configuration
test-configuration-name-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.-disable-concurrent-destination-testing-maximum-concurrent-test-device-destinations
number-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.-maximum-concurrent-test-simulator-destinations
number-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.-parallel-testing-enabled
[YES | NO]-parallel-testing-worker-count
number-maximum-parallel-testing-workers, if it is
specified.-maximum-parallel-testing-workers
number-parallelize-tests-among-destinations-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).-test-timeouts-enabled
[YES | NO]-default-test-execution-time-allowance
seconds-maximum-test-execution-time-allowance
seconds-test-iterations
number-retry-tests-on-failure or
-run-tests-until-failure, in which case this will
become the maximum number of iterations.-retry-tests-on-failure-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.-run-tests-until-failure-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.-test-repetition-relaunch-enabled
[YES | NO]-test-iterations,
-retry-tests-on-failure, or
-run-tests-until-failure. If not specified, tests
will repeat in the same process.-collect-test-diagnostics
[on-failure | never]-enumerate-tests-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.-test-enumeration-style
[hierarchical | flat]-skip-testing and
-only-testing options.-test-enumeration-format
[text | json]-test-enumeration-output-path
[path | -]-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).-dry-run,
-n-scheme is passed.A detailed reference of Xcode build settings can be found at:
⟨URL:
https://developer.apple.com/documentation/xcode/build-settings-reference
⟩
-toolchain
[identifier | name]-quiet-verbose-version-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.-license-checkFirstLaunchStatus-runFirstLaunch-downloadAllPlatforms-usagexcodebuild.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:
macOSiOSiOS SimulatorwatchOSwatchOS SimulatortvOStvOS SimulatorvisionOSvisionOS SimulatorDriverKitSome 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:
XCODE_XCCONFIG_FILE-xcconfig
option.TEST_RUNNER_<VAR>xcodebuild exits with codes defined by
sysexits(3). It will exit with
EX_OK on
success. On failure, it will commonly exit with
EX_USAGE
if any options appear malformed,
EX_NOINPUT
if any input files cannot be found,
EX_IOERR
if any files cannot be read or written, and
EX_SOFTWARE
if the commands given to xcodebuild fail. It may exit with other codes in
less common scenarios.
xcodebuild
clean installCleans the build directory; then builds and installs the first
target in the Xcode project in the directory from which
xcodebuild was started.
xcodebuild
-project MyProject.xcodeproj -target Target1 -target Target2 -configuration
DebugBuilds the targets Target1 and Target2 in the project MyProject.xcodeproj using the Debug configuration.
xcodebuild
-target MyTarget OBJROOT=/Build/MyProj/Obj.root
SYMROOT=/Build/MyProj/Sym.rootBuilds the target
MyTarget 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.
xcodebuild
-sdk macosx10.6Builds 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.
xcodebuild
-workspace MyWorkspace.xcworkspace -scheme MySchemeBuilds the scheme MyScheme in the Xcode workspace MyWorkspace.xcworkspace.
xcodebuild
archive -workspace MyWorkspace.xcworkspace -scheme MySchemeArchives the scheme MyScheme in the Xcode workspace MyWorkspace.xcworkspace.
xcodebuild
build-for-testing -workspace MyWorkspace.xcworkspace -scheme MyScheme
-destination generic/platform=iOSBuild 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.
xcodebuild
test-without-building -workspace MyWorkspace.xcworkspace -scheme MyScheme
-destination 'platform=iOS Simulator,name=iPhone 5s' -destination
'platform=iOS,name=My iPad'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.)
xcodebuild
test-without-building -xctestrun MyTestRun.xctestrun -destination
'platform=iOS Simulator,name=iPhone 5s' -destination 'platform=iOS,name=My
iPad' 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.
xcodebuild
test -workspace MyWorkspace.xcworkspace -scheme MyScheme -destination
'platform=macOS,arch=x86_64'Tests the scheme MyScheme in the Xcode workspace MyWorkspace.xcworkspace using the destination described as My Mac 64-bit in Xcode.
xcodebuild
test -workspace MyWorkspace.xcworkspace -scheme MyScheme -destination
'platform=macOS,arch=x86_64' -only-testing
MyTests/FooTests/testFooWithBarTests 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.
xcodebuild
-exportArchive -archivePath MyMobileApp.xcarchive -exportPath
ExportDestination -exportOptionsPlist 'export.plist'Exports the archive MyMobileApp.xcarchive to the path ExportDestination using the options specified in export.plist.
xcodebuild
-exportLocalizations -project MyProject.xcodeproj -localizationPath
MyDirectory -exportLanguage zh-hans -exportLanguage es-MXExports two XLIFF files to MyDirectory from MyProject.xcodeproj containing development language strings and translations for Simplified Chinese and Mexican Spanish.
xcodebuild
-exportLocalizations -project MyProject.xcodeproj -localizationPath
MyDirectoryExport a single XLIFF file to
MyDirectory from
MyProject.xcodeproj containing only development
language strings. (In this case, the
-exportLanguage parameter has been
excluded.)
xcodebuild
-importLocalizations -project MyProject.xcodeproj -localizationPath
MyLocalizations.xliffImports 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 |