xcode select - macOS


Overview

The xcode-select command allows developers to manage the active version of Xcode and the active SDK in the command line interface. It provides control over which Xcode version and SDK will be used by tools and commands that rely on them, ensuring compatibility and consistency in the development environment.

Syntax

xcode-select [options] [<action>]

Options/Flags

  • -switch <path_to_xcode.app>: Switches the active Xcode installation to the specified path.
  • -install: Installs the active Xcode version’s command-line tools without installing the entire Xcode application.
  • -uninstall: Uninstalls the active Xcode version’s command-line tools.
  • -reset: Resets the active Xcode installation to the system default.
  • -version: Prints the version of xcode-select.
  • -help: Displays the help message and exits.

Examples

Switch to a specific Xcode version:

sudo xcode-select -switch /Applications/Xcode14.app

Install command-line tools for the active Xcode version:

xcode-select -install

Reset to the system default Xcode installation:

sudo xcode-select -reset

Common Issues

  • Permission denied: When using sudo to change the active Xcode installation, ensure you have sufficient administrative privileges.
  • Xcode not found: If xcode-select cannot find an Xcode installation, verify that Xcode is installed and accessible.

Integration

xcode-select can be used in conjunction with other commands to enhance development workflows:

  • Build with a specific SDK: Use xcodebuild with -sdk flag to specify the SDK version set by xcode-select.
  • Check for Xcode updates: Use softwareupdate --list to check for available Xcode updates and install them using softwareupdate --install.
  • xcodebuild
  • softwareupdate