Fixing “tool ‘xcodebuild’ requires Xcode” without installing Xcode
1 min readMay 3, 2019
During some node.js stuff i’ve occured this error on packages build:
xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance
But in reality, Xcode is actually not always required to successfully build packages.
And here’s how to trick it:
To success, build process requires xcodebuild to return correct version information, so we just create a fake xcodebuild that return version and pass everything else to original file.
Step 1. cd /usr/bin
Step 2. Copy original xcodebuild: sudo mv xcodebuild xcodebuild.orig
Step 3. Create a fake xcodebuild:
sudo vim xcodebuild
Then paste this:
#!/bin/bash
if [[ $1 == '-version' ]]; then
echo "Xcode 10.2.1"
echo "Build version 10E1001"
else
/usr/bin/xcodebuild.bak $@
fi
(based on this article)
Step 4. Make it executable: sudo chmod +x xcodebuild
Now you can install your packages!