xcode-select

Manages active developer directory for Xcode and BSD tools.

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

Controls the location of the developer directory used by xcrun, xcodebuild, cc, and other Xcode and BSD development tools as well as the locations that are searched for by man.

Allows switching 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 (e.g. /Applications/Xcode.app, containing the latest Xcode, and /Applications/Xcode-DP.app containing a developer preview) use xcode-select --switch path/to/Xcode.app to specify the Xcode for command line tools.

xcode-select provided tool shims (see FILES) invoke the version inside the selected directory. Your own scripts, makefiles, and other tools can use xcrun to easily lookup tools in the developer directory, allowing them to function properly where the Xcode has is installed to a non-default location.

-s path
--switch path
Sets the active developer directory. Requires root. Affects all users .
for only the current shell session, use $DEVELOPER_DIR=
-r
--reset
Unsets user-specified directory. Requires root. affects all users.
-p
--print-path
xcode-select -p
/Library/Developer/CommandLineTools
--install Opens a dialog to request installation of the command tools.
xcode-select: note: install requested for command line developer tools
                "Install now?"
-h
--help
 
-v
--version
as of Ventura 6/05/23 : 2397.

$DEVELOPER_DIR
Overrides the active developer directory.

Examples

Select /Applications/Xcode.app/Contents/Developer as the active developer directory.
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Yosemite use xcode-select --switch path/to/Xcode.app

select /Applications/Xcode.app/Contents/Developer as the active developer directory.
The content directory is inferred .

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

Run xcodebuild from the active developer directory.
/usr/bin/xcodebuild

Use xcrun to locate xcodebuild inside the active developer directory.
/usr/bin/xcrun --find xcodebuild
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild

Execute xcodebuild using an alternate developer directory.

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

FILES

to find or run arbitrary commands from the active developer directory. See xcrun /usr/bin/xcrun

Run the matching Xcode tool from with the active developer directory. /usr/bin/agvtool /usr/bin/desdp /usr/bin/ibtool /usr/bin/ictool /usr/bin/instruments /usr/bin/iprofiler /usr/bin/opendiff /usr/bin/sdef /usr/bin/sdp /usr/bin/xcodebuild /usr/bin/xed Run the matching BSD tool from with the active developer directory, specify /usr/bin/ ie

usr/bin/BuildStrings
       CpMac            DeRez           GetFileInfo     MergePef    MvMac
       ResMerger        RezDet          RezWack         Rez         SetFile    SplitForks
       UnRezWack        ar      as      asa  bison  c89 c99  clang++ clang
       cmpdylib         codesign_allocate   cpp     ctags   ctf_insert
       dsymutil         dwarfdump       flex++ flex     g++         gcc gatherheaderdoc  
       gcov             git-cvsserver   git-receive-pack git-shell  git-upload-archive
       git-upload-pack  git             gm4             gnumake     gperf hdxml2manxml head-
       erdoc2html       indent          install_name_tool   ld      lex  libtool  lipo
       lldb             lorder          m4      make    mig  mkdep  nasm  ndisasm
       nm               nmedit          otool           pagestuff   ranlib rebase redo_prebinding
       resolveLinks     rpcgen          segedit         size        strings  strip  svn
       svnadmin         svndumpfilter   svnlook         svnserve    svnsync  svnversion
       unifdef          unifdefall      xml2man         yacc
There should be symlinks between binaries in /Library/Developer/CommandLineTools/ and /usr/bin/
 > xcode-select -p
/Volumes/Macintosh HD/Applications/Xcode.app/Contents/Developer
> ls -l "/Volumes/Macintosh HD/Applications/Xcode.app/Contents/Developer"
drwxr-xr-x   5 root  wheel  170 Apr 26 19:49 Applications/
drwxr-xr-x   3 root  wheel  102 Mar  2 21:30 Documentation/
drwxr-xr-x   8 root  wheel  272 Apr 26 19:58 Library/
drwxr-xr-x   6 root  wheel  204 Apr 26 19:58 Makefiles/
drwxr-xr-x   9 root  wheel  306 Apr 26 19:46 Platforms/
drwxr-xr-x   3 root  wheel  102 Feb 10 19:16 Toolchains/
drwxr-xr-x  16 root  wheel  544 May  4 19:01 Tools/
drwxr-xr-x   6 root  wheel  204 Apr 26 19:49 usr/

> cd "/Volumes/Macintosh HD/Applications/Xcode.app/Contents/Developer"
/Volumes/Macintosh HD/Applications/Xcode.app/Contents/Developer > du
0   ./Library/LaunchDaemons
0   ./Makefiles/VersioningSystems
8   ./Makefiles/Carbon
8   ./Makefiles/CoreOS
32  ./Library/MigrationFrameworks
52  ./Tools
84  ./Makefiles/pb_makefiles
92  ./Applications/DesktopReplayer.app
100 ./Makefiles
124 ./Applications/Simulator.app
264 ./Library/PrivateFrameworks
1540    ./usr/lib
2192    ./Library/Perl
2896    ./Library/Frameworks
5228    ./usr/bin
5572    ./Applications/Simulator (Watch).app
5788    ./Applications
5940    ./Library/Xcode
7104    ./usr/libexec
11324   ./Library
11916   ./Platforms/WatchOS.platform
42912   ./usr/share
56784   ./usr
62204   ./Platforms/AppleTVOS.platform
105596  ./Platforms/MacOSX.platform
183852  ./Platforms/iPhoneOS.platform
246368  ./Toolchains
246368  ./Toolchains/XcodeDefault.xctoolchain
450308  ./Documentation
450308  ./Documentation/DocSets
696928  ./Platforms/WatchSimulator.platform
914008  ./Platforms/AppleTVSimulator.platform
1001572 ./Platforms/iPhoneSimulator.platform
2976076 ./Platforms
3746800 .