Configuring command-line tools settings
Select the version of Xcode you want to use for command-line tools, in either Xcode settings or Terminal.
Overview
If you have multiple versions of Xcode on your Mac, you can select a specific version of the app to use for command-line tools. For example, you might want to release your app with the latest version of Xcode, while using a beta version to try out new APIs.
You can do this by selecting a default Xcode version to use for command-line tools in Xcode settings, or you can set it from the command line. To apply the change to every user account on your Mac, use either Xcode settings or the command line. To apply the change to the current shell session only, use the command line.
Check the default Xcode app for command-line tools
To identify the default Xcode app for command-line tools, choose Xcode > Settings, and click Locations in the sidebar. The Command Line Tools section of the Locations pane displays both the Xcode version number and the location of the file. [Image]
Alternatively, you can identify the Xcode version from the command line. Enter xcode-select with the --print-path option in Terminal. This command returns the path of the active developer directory for Xcode. For example, the following command prints the path of the developer directory containing a version of Xcode:
% xcode-select --print-path
/Applications/Xcode.app/Contents/DeveloperIf you install the Command Line Tools for Xcode package and set it as the active directory, the command xcode-select --print-path returns the package path, like in the following example:
% xcode-select --print-path
/Library/Developer/CommandLineToolsIf you have no active developer directory on your macOS computer, this command prints the following message:
% xcode-select --print-path
xcode-select: error: Unable to get active developer directory. Use
sudo `xcode-select --switch <path/to/>Xcode.app` to set one
(or see man xcode-select)Select the default Xcode app
To change the default Xcode app for the command-line tools in Xcode, choose a different version of the app from the pop-up menu in Locations settings, under Command Line Tools. The pop-up menu contains the name and build of every Xcode app installed on your Mac.
[Image] Enter your administrator password when the system prompts you to confirm the change.
Alternatively, you can set the default Xcode app for command-line tools in Terminal, using the xcode-select command. Enter xcode-select with the --switch option in Terminal:
% sudo xcode-select --switch <path>In this command, <path> specifies a path to the developer directory of the Xcode app or to the Command Line Tools for Xcode package you want to use.
For example, the following command selects a beta version of Xcode:
% sudo xcode-select --switch /Applications/Xcode-beta.appTo select the Command Line Tools for Xcode package, run the following command:
% sudo xcode-select --switch /Library/Developer/CommandLineToolsSelect the default Xcode app temporarily
If you want to keep the default Xcode app for the command-line tools and use a command from a different version of Xcode, set the DEVELOPER_DIR environment variable when you invoke the command in Terminal:
% env DEVELOPER_DIR="<path>" <command>The environment variable overrides the active developer directory and doesn’t require superuser permissions. It takes the path of the developer directory of the Xcode app or the Command Line Tools for Xcode package you want to use.
For example, the following command gathers a sysdiagnose from a connected device and saves it at a specific location:
% env DEVELOPER_DIR="/Applications/Xcode-beta.app" xcrun devicectl device sysdiagnose --device "Work iPad" --destination ~/Downloads --gather-full-logs