Last active
September 12, 2019 08:16
-
-
Save ignazioc/ebd7901e91e469bb60e2d64cae05d65f to your computer and use it in GitHub Desktop.
Switch between xcode versions
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/ruby | |
xcodes = Dir["/Applications/Xcode*"] | |
if xcodes.count.zero? | |
puts "No Xcode installed" | |
exit 0 | |
end | |
selected_index = -1 | |
loop do | |
puts "Which Xcode do you want to use?" | |
xcodes.each_with_index do | xcode, index | | |
puts " #{index}) #{xcode}" | |
end | |
selected_index = gets.to_i | |
break if (selected_index >= 0 && selected_index < xcodes.count) | |
end | |
cmd = "xcode-select -s '#{xcodes[selected_index]}/Contents/Developer'" | |
exec(cmd) | |
# How to use: | |
# 1. Download the script | |
# 2. Make it executable `chmod +x xcodeswitch.rb` | |
# 3. Run `./xcodeswitch.rb` | |
# | |
# | |
# Which Xcode do you want to use? | |
# 0) /Applications/Xcode-10.2.app | |
# 1) /Applications/Xcode-10.3.app | |
# 2) /Applications/Xcode-11-gm.app | |
# 3) /Applications/Xcode-11-beta3.app | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment