It seems that Xcode really likes to be in the Applications folder and be called Xcode, especially when using
xcodebuild (when building for Carthage for example) - and
xcode-select doesn't always seem to cut it.
I have a client project that's still using Swift 2.2, and I'm stuck on Xcode 7 for that and using Xcode 8 for anything else.
So, in my Applications folder, I have Xcode 7 (renamed to Xcode_7) and Xcode 8 (renamed to Xcode_8). Then I rename whichever one I need to simply Xcode, and back again when done. It's a ball-ache, but seems to work.
This shell script simplifies it a bit…
if [[ $1 = "-8" ]]
if [ -e Xcode_8.app ]
mv Xcode.app Xcode_7.app
mv Xcode_8.app Xcode.app
echo "Switched to Xcode 8"
echo "Already using Xcode 8"
elif [[ $1 = "-7" ]]
if [ -e Xcode_7.app ]
mv Xcode.app Xcode_8.app
mv Xcode_7.app Xcode.app
echo "Switched to Xcode 7"
echo "Already using Xcode 7"
echo "usage: xcode-version -7/8"
xcode-select --switch Xcode.app