Unable to locate Xcode. Please make sure to have Xcode installed on your machine
Try check Preferences in Xcode under Locations and be sure you have selected your Xcode version in the Command Line Tools dropdown:
CLI approach:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer