Quick answer
Run sudo xcode-select -s /Applications/Xcode.app/Contents/Developer, then verify with xcodebuild -version. If Xcode isn't installed, install it from the App Store first.
Why this happens
I've seen this error more times than I can count—usually right after a fresh macOS setup or a system update. You're trying to build something, maybe with Flutter or a React Native project, and boom: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance. Frustrating, right? The core issue is that your system's default developer directory points to the Command Line Tools package, which gives you tools like clang and git, but not the full xcodebuild binary. That only ships with the complete Xcode app.
This often happens when you run xcode-select --install to get Command Line Tools, but you never installed Xcode itself. Or maybe you had Xcode and it got moved or renamed. Either way, the fix is straightforward—point xcode-select to the real Xcode.
Fix steps
- Check if Xcode is installed. Open Finder and look in /Applications for Xcode.app. If you don't see it, head to the Mac App Store and download it. It's a big download (several GB), so grab a coffee.
- Once Xcode is installed, open a terminal. You'll want to switch the active developer directory. Run:
sudo xcode-select -s /Applications/Xcode.app/Contents/DeveloperEnter your password when prompted. This tells macOS to use the Xcode installation for developer tools.
- Verify the switch. Run
xcode-select -p— you should see/Applications/Xcode.app/Contents/Developer. Then test withxcodebuild -version. You'll see something likeXcode 15.4and a build number. If you get a version, you're good.
Alternative fixes if the main one fails
Sometimes the path is different—maybe you have Xcode in a custom location. Use xcode-select -switch with the full path to your Xcode's Developer folder. For example:
sudo xcode-select -s /Applications/Xcode-beta.app/Contents/DeveloperIf you're seeing this error in a CI environment or a fresh machine, you might just need to install Command Line Tools instead, then use the clang tools. But if you specifically need xcodebuild, the full Xcode is required. No way around that.
Also, check if Xcode's license hasn't been accepted. Run sudo xcodebuild -license and type agree if it prompts. I've seen that cause weird build failures too.
Prevention tip
To avoid this headache in the future, after you install Xcode, immediately run sudo xcode-select -s /Applications/Xcode.app/Contents/Developer. Make it part of your setup routine. I've also seen systems automatically reset the developer directory after a macOS update, so if the error reappears after an update, you know exactly what to check.
One more thing: if you're using Homebrew, sometimes it expects Command Line Tools. Don't stress—you can have both. Just point xcode-select to Xcode, and Homebrew will still work fine. I've been running this setup for years without issues.