Created
June 17, 2017 13:29
-
-
Save JohnSundell/620c3d12aca69fbe259f69391cc532f8 to your computer and use it in GitHub Desktop.
A script that switches between the App Store & beta versions of Xcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# This script switches between the App Store version of Xcode and the beta | |
# Install it by copying it to /usr/local/bin/xcode-switch and running 'chmod +x' on it (to make it executable) | |
# Then run it using 'sudo xcode-switch' | |
if [ "$EUID" -ne 0 ]; then | |
echo "xcode-select requires you to run this script as root; 'sudo xcode-switch'" | |
exit | |
fi | |
currentPath=$(xcode-select -p) | |
if [ "$currentPath" == "/Applications/Xcode.app/Contents/Developer" ]; then | |
xcode-select -s "/Applications/Xcode-beta.app/Contents/Developer" | |
else | |
xcode-select -s "/Applications/Xcode.app/Contents/Developer" | |
fi | |
newPath=$(xcode-select -p) | |
echo "Xcode path is now $newPath" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Alternative idea (not tested), to avoid requiring
sudo
and instead switch the Xcode version on a per-invocation basis: