Skip to content

Instantly share code, notes, and snippets.

@ignazioc
Last active September 12, 2019 08:16
Show Gist options
  • Save ignazioc/ebd7901e91e469bb60e2d64cae05d65f to your computer and use it in GitHub Desktop.
Save ignazioc/ebd7901e91e469bb60e2d64cae05d65f to your computer and use it in GitHub Desktop.
Switch between xcode versions
#!/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