FYI, using fredpi's working solution above has some caveats which I discussed with my coworkers. From nglevin (slightly paraphrased to redact names), this solution may cure some side-effects from using fredpi's solution:
One caveat to raise about this; changing Xcode's root info plist, may corrupt part of macOS's Launch Services database, a legacy API for which is still used by xcode-select (not all modern production macs do, but some developer environments may).
This will make it challenging to use sudo xcode-select -s /path/to/Xcode.app
to select a given Xcode; your Launch Services database will be stuck on whatever Xcodes it found before the plist change.
To rebuild the Launch Services database, do this in your Mac's terminal:
sudo lsregister -kill -r -domain local -domain system -domain user
And your next sudo xcode-select -s
... invocation should succeed.
The application cannot be opened for an unexpected reason, error=Error Domain=NSOSStatusErrorDomain Code=-10664 "kLSIncompatibleApplicationVersionErr: The app is incompatible with the current OS" UserInfo={_LSLine=4087, _LSFunction=_LSOpenStuffCallLocal}
just kill the command and try again, it should work ! – Trap