xcode-select: error: tool ‘xcodebuild’ requires Xcode, but active developer directory

Error:

[fatal] xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

The solution for the above error is to run the following command:

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

The above code will set the the command line tools path of XCode.

Run the following command to confirm that the path has been set:

xcode-select --print-path

Output:

/Applications/Xcode.app/Contents/Developer