Failed to find Xcode installed with Metal Compiler. Please install Xcode and run Xcode.app to accept the agreement, or make sure the active developer directory is set to the current Xcode installation

Failed to find Xcode installed with Metal Compiler. Please install Xcode and run Xcode.app to accept the agreement, or make sure the active developer directory is set to the current Xcode installation (using xcode-select).

You must install XCode version 13.something, and run it at least once to set it up correctly. Then make sure version 13 toolpath is selected in preferences.
Current version you get by default from Apple is 14, so you have to go to developer support downloads and download the last version of 13.x