TLDR; Use the following to completely destroy all your iOS Simulators and to create a new batch.
curl "https://gist.githubusercontent.com/cabeca/cbaacbeb6a1cc4683aa5/raw/8e17f39f5a7413fd0559c9e6808e01b6fb514422/simulator_populator" -o "simulator_populator.rb" && chmod +x simulator_populator.rb && ./simulator_populator.rb
While trying out the new Xcode 7 beta’s, this happened to me… a lot…
Looks like the different Xcode’s have varying ideas about when to install new devices and just go for safe. If you install a lot of new beta’s, this might look familiar to you.
While searching for the solution I came across the command line tool and options:
> xcrun simctl list
> xcrun simctl delete <device>
> xcrun simctl create <name> <device type id> <runtime id>
Using some regex witchcraft, I placed the entire list of device UUIDs in a file and deleted all my simulators and installed a couple of new ones. And of course, I vowed to create a script to avoid having to do this manually again.
Instead, I got the following tweet a while later;
Thanks @miguelcabeca for https://t.co/blruwarSo9! I finally have a nice list of simulators again. (cc @brunoscheele) pic.twitter.com/SxxuOqYnbk
— Thomas Visser (@thomvis) July 28, 2015
@miguelcabeca has gifted us with this wonderfull little script;
#!/usr/bin/env ruby | |
device_types_output = `xcrun simctl list devicetypes` | |
device_types = device_types_output.scan /(.*) \((.*)\)/ | |
runtimes_output = `xcrun simctl list runtimes` | |
runtimes = runtimes_output.scan /(.*) \(.*\) \((com.apple[^)]+)\)$/ | |
devices_output = `xcrun simctl list devices` | |
devices = devices_output.scan /\s\s\s\s(.*) \(([^)]+)\) (.*)/ | |
devices.each do |device| | |
puts "Removing device #{device[0]} (#{device[1]})" | |
`xcrun simctl delete #{device[1]}` | |
end | |
device_types.each do |device_type| | |
runtimes.each do |runtime| | |
puts "Creating #{device_type} with #{runtime}" | |
command = "xcrun simctl create '#{device_type[0]} #{runtime[0]}' #{device_type[1]} #{runtime[1]}" | |
command_output = `#{command}` | |
sleep 0.5 | |
end | |
end |
Save that somewhere, make it executable and run it. You’ll have a nice clean list of iOS Simulators once more!