Set Xcode Version Using DEVELOPER_DIR
Environment Variable
export DEVELOPER_DIR="/Applications/Xcode-15.1.0.app/Contents/Developer"
The nice thing about this method is that it does not require admin credentials, and can be set either globally or for a specific shell session.
source: https://github.com/klaaspieter/chxcode