I encountered the same errors recently!
The errors appeared for me after I installed command line tools, which I needed only temporarily. I fixed it by deleting /Library/Developer/CommandLineTools
and running sudo xcode-select -s /Applications/Xcode.app
(11.4). Maybe there's a more robust solution.