Last active
August 29, 2015 14:16
-
-
Save jfro/8743ff70ea8e427e541d to your computer and use it in GitHub Desktop.
Erase all simulators
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
#!/bin/env ruby | |
xcodes = Dir.glob("/Applications/Xcode*.app") | |
puts xcodes | |
xcodes.each do |xcode| | |
simctl = "#{xcode}/Contents/Developer/usr/bin/xcrun simctl" | |
puts "#{simctl} list" | |
out = %x{#{simctl} list} | |
out.lines.each do |line| | |
match = /(\s+)(.*)\s\(([\d\w]{8}-[\w\d]{4}-[\w\d]{4}-[\w\d]{4}-[\w\d]{12})\)/.match(line) | |
if match | |
id = match[3] | |
name = match[2] | |
puts "Erasing #{name} (#{id})" | |
result = system("#{simctl} erase #{id}") | |
if not result | |
puts "Failed to erase #{name} - #{id}" | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment