If you get the error one resolution is to download the command line tools. Open a terminal and pass the following command and run it. A Dialog will open an help with the download and install.
xcodebuild -downloadComponent MetalToolchain