“xcodebuild requires Xcode”: fix the active developer directory
Point the active developer directory at Xcode.app with xcode-select.
The command line tools are active instead of Xcode. Run sudo xcode-select -s /Applications/Xcode.app/Contents/Developer, then confirm with xcode-select -p.
Try these fixes in order
Confirm the active developer directory
Run xcode-select -p to see the active developer directory. If it prints /Library/Developer/CommandLineTools or a path that no longer exists, that is the problem.
xcode-select -pSwitch to the Xcode developer directory
Point the active developer directory at the Xcode installation. Adjust the path if Xcode.app lives somewhere other than /Applications.
sudo xcode-select -s /Applications/Xcode.app/Contents/DeveloperVerify xcodebuild works
Re-run xcode-select -p and then xcodebuild -version. xcodebuild should now report the Xcode version instead of the xcode-select error.
xcode-select -pxcodebuild -versionInterpret what you see
The error says the active developer directory is a command line tools instance
What it suggests: xcode-select -p reports /Library/Developer/CommandLineTools, which cannot run xcodebuild or the iOS SDK toolchains.
Next check: Run xcode-select -p to confirm the current path.
The printed developer directory path does not exist
What it suggests: The path stored by xcode-select no longer exists because Xcode.app was moved, renamed, or removed.
Next check: Run xcode-select -p and check whether the printed path exists in Finder or with ls.
The error happens in one terminal or CI job but not others
What it suggests: Scripts or CI jobs set DEVELOPER_DIR or call xcode-select, overriding the system default for that shell only.
Next check: Check whether DEVELOPER_DIR is set in the failing shell with echo $DEVELOPER_DIR.
Why this happens
- The active developer directory points to the standalone command line tools instead of Xcode.app.
- Xcode was moved, renamed, or deleted after the developer directory was last set.
Still not working?
Installing additional command line tools packages or reinstalling Xcode will not change the active developer directory; only xcode-select changes it. Do not delete the CommandLineTools directory as a workaround, since other tools depend on it.
Official sources
These steps are based on the linked documentation and general diagnostics. BugMedic has not independently tested every product and system configuration. Review commands before running them.