Skip to content

xcode-select command in MacOS

The xcode-select command in MacOS is a useful tool for managing command line tools and switching between different versions of Xcode. By using xcode-select, users can easily switch between different Xcode installations, set the active developer directory, and install additional components. This command is especially handy for developers who work with multiple versions of Xcode or need to switch between different versions for compatibility or testing purposes.

xcode-select Syntax:

Terminal window
xcode-select [option] [parameter]

MacOS xcode-select Options:

OptionDescription
—install-selectInstall the selected version of Xcode.
—switchSwitch the active developer directory to the specified directory.
—print-pathPrint the path of the selected Xcode developer directory.
—versionPrint the installed Xcode version.
—resetReset to the default Xcode path.

xcode-select Parameters:

ParameterDescription
pathThe path to the Xcode developer directory.

How to use xcode-select command:

Terminal window
xcode-select --print-path

Displays the current active developer directory.

Switch to a different developer directory

Terminal window
sudo xcode-select -switch /Applications/Xcode-beta.app

Changes the active developer directory to the one specified.

Reset the developer directory to the default

Terminal window
sudo xcode-select --reset

Resets the active developer directory to the default location.

Verify the active developer directory

Terminal window
xcode-select --version

Shows the active developer directory version.

Terminal window
xcode-select --print-default-path

Displays the complete path to the active developer directory.

Check if the Xcode command line tools are installed

Terminal window
xcode-select -p

Verifies if the Xcode command line tools are installed.

List available developer directories

Terminal window
xcode-select -s

Lists all the available developer directories.

Help command for xcode-select

Terminal window
xcode-select -h

Shows the help documentation for the xcode-select command.

How do I set the path for xcode-select in MacOS using a command line interface?

To set the path for xcode-select in MacOS using a command line interface, execute the following command:

Terminal window
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer

How do I reset xcode-select to its default location in MacOS?

To reset xcode-select to its default location in MacOS, execute the following command:

Terminal window
sudo xcode-select --reset

How do I update xcode-select in MacOS to the latest version of Xcode?

To update xcode-select in MacOS to the latest version of Xcode, execute the following command:

Terminal window
xcode-select --install

How can I check the version of xcode-select installed on my MacOS system?

To check the version of xcode-select installed on your MacOS system, execute the following command:

Terminal window
xcode-select --version

How do I change the developer directory path with xcode-select in MacOS?

To change the developer directory path with xcode-select in MacOS, execute the following command:

Terminal window
sudo xcode-select --switch /path/to/new/developer/directory

How do I list the available paths that xcode-select can switch to in MacOS?

To list the available paths that xcode-select can switch to in MacOS, execute the following command:

Terminal window
xcode-select --list

How do I uninstall xcode-select from MacOS using a terminal command?

To uninstall xcode-select from MacOS using a terminal command, execute the following command:

Terminal window
sudo rm -rf /Library/Developer/CommandLineTools

How do I change the SDK path setting using xcode-select in MacOS?

To change the SDK path setting using xcode-select in MacOS, execute the following command:

Terminal window
sudo xcode-select -s /path/to/new/SDK

Applications of the xcode-select command

  • Switching between different versions of Xcode
  • Specifying which version of Xcode to use for command line tools