Fixing “xcode-select: error: tool ‘xcodebuild’ requires Xcode…” with one click

Going through the instructions for building Chromium from source on Macintosh, I ran into this weird error:

% gn gen out/Default
ERROR at //build/config/mac/mac_sdk.gni:133:19: Script returned non-zero exit code.
_mac_sdk_result = exec_script(script_name, sdk_info_args, "scope")
                  ^----------
...
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

This was (and remains) mysterious to me because I do have Xcode installed along with the commandline tools.

I was also able to generate the same error message by calling xcodebuild directly:

% xcodebuild
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

A Stack Overflow user mentioned that simply clicking on the Command Line Tools dropdown in Preferences fixed the issue (https://stackoverflow.com/a/72115137). Weird. I was thrown off a bit because the name for “Preferences” has changed to “Settings” in the meantime and also the UI widget in question now lives under the “Locations” tab. (Er, but I see a comment addressing this: “As of 2024, it’s now XCode > Settings.” Oops.) Otherwise, it’s still working. But it worked… what the heck?

Unlike what’s shown in the Stack Overflow user’s screenshot, the dropdown was already populated. Clicking it brought up an authorization dialog… and after approving something or other, it works. Huh?

I didn’t notice anything that changed in the UI. Nor did anything in the UI give an indication that a click was needed.

Here are some old docs (2017?) on xcodebuild: https://developer.apple.com/library/archive/technotes/tn2339/_index.html (Archive). Any more recent sources of authoritative info on it? Or has not much changed?

Anyway, I’m a little uncomfortable with the mystery of why clicking that dropdown menu fixed anything, but here’s a post for search engines to find in case you (perhaps a later iteration of myself) run into the same problem.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *