clang: error: unable to locate xcodebuild

ctt25 picture ctt25 · Sep 29, 2018 · Viewed 9.2k times · Source

I am using a mac version 10.13.6.

I want to compile C programs through the terminal. I've downloaded Xcode and the command line tools. When I type clang --version in the terminal, I get the following two error messages:

clang: error: unable to locate xcodebuild, please make sure the path to the Xcode folder is set correctly!

clang: error: You can set the path to the Xcode folder using /usr/bin/xcode-select -switch

I did some googling and found a fix here. The solution is to run the following line in terminal:

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

Which I did. But when I enter clang --version after doing this, I get exactly the same two errors. What's going on?

NB: very very new to this so please keep that in mind when answering! cheers

Answer

AdamWinsche picture AdamWinsche · Nov 24, 2018
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer 

worked like a charm for me