You need to run the below command to squash the error
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer/
Note: Depending on your Xcode version installed, sometimes you have to add it to the path, for example sudo xcode-select -s /Applications/Xcode_12.0.app/Contents/Developer/