48

With the release of Apple's Command Line Toolkit for Xcode, I am trying to avoid needing to install Xcode proper. In order to do this, I need to set the path to xcode for specific make files that depend on the xcode-select path (which is currently pointing to /Developer)

Where do I point the xcode-select path when using the CLI Toolkit for Xcode?

If I install Xcode, it's just /Applications/Xcode.app, but I don't know where the CLI Toolkit is being placed.

Thanks.

UPDATE:

It appears from the pkg installer that it dumps it all to /usr/bin and then xcode-select or other scripts internal to the pkg create the paths for xcodebuilder etc. Can anyone confirm?

Lukas
  • 3,175
  • 2
  • 25
  • 34

5 Answers5

99
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
Cœur
  • 37,241
  • 25
  • 195
  • 267
billzhong
  • 1,386
  • 10
  • 9
  • 1
    is this the case if I haven't installed Xcode.app? Or does the CLI Toolkit install to Xcode.app? – Lukas Mar 14 '12 at 19:21
  • Try this: https://github.com/kennethreitz/osx-gcc-installer if your only need gcc or etc. – billzhong Mar 19 '12 at 01:46
  • you save me! mac ports suggests to run `sudo xcode-select -switch /Applications/Xcode.app` which makes no sense :( – deadrunk Apr 12 '12 at 08:01
  • 1
    so i still want to know, does the xcodebuild tool get installed to /Applications/Xcode.app if I dont install Xcode. It doesnt seem to make sense that it would. – Lukas Jun 07 '12 at 01:40
  • This may be obvious, but if you have installed XCode Beta version you need to run `sudo xcode-select -switch /Applications/Xcode-Beta.app/Contents/Developer` instead. – jsalonen Sep 15 '15 at 19:41
  • Your answer is loook same as https://stackoverflow.com/a/9600674/11077258 this answer – steveSarsawa Dec 04 '19 at 10:25
  • @deadrunk You don't need to use the path to `Developer`. Just setting the path as mac ports indicates also works. – ThomasW Nov 12 '21 at 03:23
32

I installed the CLI tools only (e.g. no Xcode) and received an error with a native gem extension build:

xcode-select: Error: No Xcode is selected. Use xcode-select -switch <path-to-xcode>, or see the xcode-select manpage (man xcode-select) for further information.

After looking at this and browsing the directories, it appears the BSD tools got installed in /usr/bin therefore:

sudo xcode-select -switch /

seems to work.

NoNameProvided
  • 8,608
  • 9
  • 40
  • 68
chrischris
  • 1,241
  • 10
  • 4
19

Just did this today after removing Xcode to reclaim HD space. I used:

sudo xcode-select -s /Library/Developer/CommandLineTools
Ben Mosher
  • 13,251
  • 7
  • 69
  • 80
6

I encountered this problem recently because I had several XCode versions installed on the same machine. If you have one or more XCode previously installed, you can simply reset the path with the command:

sudo xcode-select -r

This will reset the path to the default, which is /Library/Developer/CommandLineTools.

Seto
  • 1,234
  • 1
  • 17
  • 33
1

For my setup (Xcode 4.0.2 on 10.6.8), I used spotlight to search for 'xcodebuild' to find where the Xcode CLI tools actually live.

The CLI tools are in /Developer/usr/bin, so my xcode-select command looks like (the /usr/bin is appended by xcode-select):

sudo xcode-select -switch /Developer
Amir Rubin
  • 850
  • 7
  • 11