xcode-select

Manage the active developer directory for Xcode and BSD tools.

Syntax
      xcode-select [-h|--help] [-s|--switch path] [-p|--print-path] [-v|--version]

Key
   -h, --help
           Print the usage message.

   -s path, --switch path
           Sets the active developer directory to the given path, for example /Applications/Xcode-beta.app.
           This command must be run with superuser permissions (see sudo), and will affect all users on the system.
           To set the path without superuser permissions or only for the current shell session, use the DEVELOPER_DIR 
           environment variable instead (see ENVIRONMENT).

   -p, --print-path
           Prints the path to the currently selected developer directory.
           This is useful for inspection, but scripts and other tools should use xcrun(1) to locate tool
           inside the active developer directory.

   -r, --reset
           Unset any user-specified developer directory, so that the developer directory will be found via
           the default search mechanism. This command must be run with superuser permissions (see sudo), and
           will affect all users on the system.
   -v, --version
           Print xcode-select version information.

   --install
           Open a user interface dialog to request automatic installation of the command line developer tools.

xcode-select controls the location of the developer directory used by xcrun(1), xcodebuild(1), cc(1), and other Xcode and BSD development tools. This also controls the locations that are searched for by man(1) for developer tool manpages.

This allows you to easily switch between different versions of the Xcode tools and can be used to update the path to the Xcode if it is moved after installation.

When multiple Xcode applications are installed on a system (e.g. /Applications/Xcode.app, containing the latest Xcode, and /Applications/Xcode-beta.app containing a beta) use xcode-select --switch path/to/Xcode.app to specify the Xcode that you wish to use for command line developer tools.

After setting a developer directory, all of the xcode-select provided developer tool shims (see FILES) will automatically invoke the version of the tool inside the selected developer directory. Your own scripts, makefiles, and other tools can also use xcrun(1) to easily lookup tools inside the active developer directory, making it easy to switch them between different versions of the Xcode tools and allowing them to function properly on systems where the Xcode application has been installed to a non-default location.

ENVIRONMENT

DEVELOPER_DIR
Overrides the active developer directory. When DEVELOPER_DIR is set, its value will be used instead of the system-wide active developer directory.

Note that for historical reason, the developer directory is considered to be the Developer content directory inside the Xcode application (for example /Applications/Xcode.app/Contents/Developer). You can set the environment variable to either the actual Developer contents directory, or the Xcode application directory -- the xcode-select provided shims will automatically convert the environment variable into the full Developer content path.

Examples

Install the command line developer tools, will prompt to download and install:

xcode-select --install

Select /Applications/Xcode.app/Contents/Developer as the active developer directory:

xcode-select --switch /Applications/Xcode.app/Contents/Developer

As above, select /Applications/Xcode.app/Contents/Developer as the active developer directory. The Developer content directory is automatically inferred by xcode-select:

xcode-select --switch /Applications/Xcode.app

Run xcodebuild out of the active developer directory:

/usr/bin/xcodebuild

Use xcrun to locate xcodebuild inside the active developer directory:

/usr/bin/xcrun --find xcodebuild

Execute xcodebuild using an alternate developer directory:

env DEVELOPER_DIR="/Applications/Xcode-beta.app" /usr/bin/xcodebuild

“Rien n'est pareil”

Related macOS commands

pkgutil - Query and manipulate installed packages
sw_vers - Print macOS operating system version.
xcrun(1)
xcodebuild(1)


 
Copyright © 1999-2024 SS64.com
Some rights reserved