Duplicated Simulators in Xcode – Quick Fix

Here’s a quick script that deletes and recreated all of your iOS simulators in Xcode 7. Use it when you get the duplicated nightmare or if you just want to reset everything:

#!/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']}`
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']} #{runtime['name']}' #{device_type['identifier']} #{runtime['identifier']}"
command_output = `#{command}`
sleep 0.5

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s