/Library/Developer/CommandLineTools
directory./usr/bin
, can map any tool included in /usr/bin
to the corresponding one inside Xcode. xcrun is one of such shims, which allows you to find or run any tool inside Xcode from the command line. Use it to invoke any tool within Xcode from the command line as shown in Listing 1. xcode-select --install
command. xcode-select
, a command-line tool that is installed in /usr/bin
. It allows you to manage the active developer directory for Xcode and other BSD development tools. See its man page for more information./Library/Developer/CommandLineTools
directory exists on your system, remove it to uninstall the command-line tools.build
, analyze
, and archive
that can be performed on your target or scheme. However, build
is performed by default when no action is specified as shown in Listing 7.-workspace
option allows you to specify the name of your workspace. Use this option when your scheme is contained in an Xcode workspace.-project
option allows you to specify the name of your Xcode project. Use this option when your scheme is contained in an Xcode project. It is required when there are multiple Xcode projects in the same directory and optional, otherwise.-destination
option allows you to specify a destination for your unit tests. It takes an argument <destination-specifier>
, which describes the device, simulator, or Mac to use as a destination. It consists of a set of comma-separated key=value pairs, which are dependent upon the the device, simulator, or Mac being used. -only-testing
and -skip-testing
options, which are optional, allow you to run only a specific test and to skip a test, respectively. They take an argument <test-identifier>
, which specifies the test to be executed or excluded. test-identifier
's format is as follows:TestTarget
, which is required, is the name of the test bundle. TestClass
and TestMethod
, which are both optional, respectively represent the name of the class and the name of the method to be tested.destinationspecifier
supports the platform and arch keys as seen in Table 1. Both keys are required for running your unit tests in macOS.Key | Description | Value |
---|---|---|
platform | The supported destination for your unit tests. | macOS |
arch | The architecture to use to run your unit tests. | i386 or x86_64 |
destinationspecifier
is set to 'platform=macOS,arch=x86_64'.destinationspecifier
supports the platform, name, and id keys as seen in Table 2. Key | Description | Value |
---|---|---|
platform | The supported destination for your unit tests. | iOS (for iOS apps)tvOS (for tvOS apps) |
name | The full name of your device to be used for your unit tests. | The name of your device as displayed in the Devices Organizer in Xcode. |
id | The identifier of your device to be used for your unit tests. | See Locate a device identifier for more information about getting your device identifier. |
destinationspecifier
supports the platform, name, id, and OS keys as seen in Table 3. Key | Description | Value |
---|---|---|
platform | The supported destination for your unit tests. | iOS Simulator (iOS apps)tvOS Simulator (tvOS apps) |
name | The full name of the simulator (iOS simulator for iOS apps and tvOS Simulator for tvOS apps) to be used for your unit tests and as displayed in the run destination of your Xcode project. | The name of your device as displayed in the Devices Organizer in Xcode. |
id | The identifier of your device to be used for your unit tests. | See Locate a device identifier for more information about getting your device identifier. |
OS | The version of iOS or tvOS to simulate such as 9.0 or the string latest to indicate the most recent version of iOS supported by your version of Xcode. | An iOS version, tvOS version, or latest |
-destination
option also allows you to run the same unit test on multiple destinations. This is done by adding it multiple times to your xcodebuild test command as demonstrated in Listing 17.build-for-testing
action for Xcode's Product > Build For > Testing feature. You must specify a scheme to use it. To use it, execute the following command in Terminal:build-for-testing
's options.build-for-testing
generates an xctestrun file, which is saved in the derived data folder. See xcodebuild.xctestrun's man page for more information about xctestrun files. test-without-building
action for Xcode's Product > Perform Action > Test Without Building feature. test-without-building
requires that you specify either a scheme or an xctestrun file. test-without-building
's options. test-without-building
searches for bundles in the build root (SYMROOT
). Therefore, be sure to build your target or that your build root includes the bundles to be tested before running this command. See Xcode Help's Build settings reference for more information about SYMROOT
.test-without-building
searches for bundles at paths specified in the file. Therefore, be sure that the bundles exist at the specified paths before running this command.build-for-testing
and test-without-building
provide support for continuous integration systems.-exportOptionsPlist
, run the following command in Terminal:<xcarchivepath>
specifies the archive or the path of the archive to be exported, <destinationpath>
specifies where to save the exported product, and <path>
is the path to the file with a list of options for the -exportOptionsPlist
flag.Date | Notes |
---|---|
2017-06-19 | Updated the 'How do I run unit tests from the command line?' question.Added the 'How do I implement the Build For Testing and Test Without Building features from the command line?' and 'What keys can I pass to the exportOptionsPlist flag?' questions. |
Updated the 'How do I run unit tests from the command line?' question.Added the 'How do I implement the Build For Testing and Test Without Building features from the command line?' and 'What keys can I pass to the exportOptionsPlist flag?' questions. | |
2014-05-21 | New document that provides answers to frequently asked questions about command-line tools. |
$
character. The $
character is a cue that you should enter a shell command. This is a longtime convention that indicates you should enter a command in the terminal application. The Unix shell command whoami
returns your username.gcc
or make
.gcc
is installed: