Skip to content

Instantly share code, notes, and snippets.

@dfreniche
Last active October 11, 2017 19:41
Show Gist options
  • Save dfreniche/3e72d845a31ce6e7590ff2cf5b790ddb to your computer and use it in GitHub Desktop.
Save dfreniche/3e72d845a31ce6e7590ff2cf5b790ddb to your computer and use it in GitHub Desktop.
Rather crude script to change between Xcode 8 and Xcode 9 selecting the correct command line tools
#!/bin/bash
# if 1st param empty...
if [ -z "$1" ]
then
echo "Usage: select-xcode {8|9}"
exit
fi
XCODE8_APP=/Applications/Xcode-8.app
XCODE9_APP=/Applications/Xcode.app
du -hs ~/Library/Developer/Xcode/DerivedData/
echo "🔥 Deleting derived data..."
rm -rf ~/Library/Developer/Xcode/DerivedData/*
echo "Closing open Simulators"
killall "Simulator"
killall "Xcode"
echo "Select command line tools"
if [ $1 == "8" ]
then
sudo xcode-select -s $XCODE8_APP/Contents/Developer/
else
sudo xcode-select -s $XCODE9_APP/Contents/Developer/
fi
echo "💻 Selected Command line tools:"
xcode-select --print-path
echo "🛠 Opening Xcode"
if [ $1 == "8" ]
then
open $XCODE8_APP
else
open $XCODE9_APP
fi
@Momachilles
Copy link

Momachilles commented Oct 11, 2017

Maybe '$HOME/Library/Developer/Xcode/DerivedData/' instead of '/Users/dfreniche/Library/Developer/Xcode/DerivedData/' could make the script for any user.

@dfreniche
Copy link
Author

True. That's why it's "rather crude" :-D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment