Skip to content

Instantly share code, notes, and snippets.

@danielribeiro
Forked from cabeca/simulator_populator_xcode7
Last active September 21, 2017 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save danielribeiro/b94b5c9a43ca3178eb89aa304737043e to your computer and use it in GitHub Desktop.
Save danielribeiro/b94b5c9a43ca3178eb89aa304737043e to your computer and use it in GitHub Desktop.
This script removes and recreates all simulators in Xcode 7.
#!/usr/bin/env ruby
require 'JSON'
device_types = JSON.parse `xcrun simctl list -j devicetypes`
runtimes = JSON.parse `xcrun simctl list -j runtimes`
devices = JSON.parse `xcrun simctl list -j devices`
devices['devices'].each do |runtime, runtime_devices|
runtime_devices.each do |device|
puts "Removing device #{device['name']} (#{device['udid']})"
`xcrun simctl delete #{device['udid']}`
end
end
device_types['devicetypes'].each do |device_type|
runtimes['runtimes'].select{|runtime| runtime['availability'] == '(available)'}.each do |runtime|
puts "Creating #{device_type['name']} with #{runtime['name']}"
command = "xcrun simctl create '#{device_type['name']}' #{device_type['identifier']} #{runtime['identifier']}"
command_output = `#{command}`
sleep 0.5
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment