lib/snapshot/reset_simulators.rb in snapshot-0.9.2 vs lib/snapshot/reset_simulators.rb in snapshot-0.9.3
- old
+ new
@@ -1,43 +1,43 @@
module Snapshot
class ResetSimulators
def self.clear_everything!(ios_version)
- # Taken from https://gist.github.com/cabeca/cbaacbeb6a1cc4683aa5
-
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# !! Warning: This script will remove all your existing simulators !!
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sure = true if ENV["SNAPSHOT_FORCE_DELETE"]
sure = agree("Are you sure? All your simulators will be DELETED and new ones will be created! (y/n)".red, true) unless sure
-
raise "User cancelled action" unless sure
-
- device_types_output = `xcrun simctl list devicetypes`
- device_types = device_types_output.scan /(.*) \((.*)\)/
-
- devices_output = `xcrun simctl list devices`.split("\n")
- devices_output.each do |line|
- device = line.match(/\s+([\w\s]+)\(([\w\-]+)\)/)
- if device and device.length == 3
- name = device[1].strip
- id = device[2]
- puts "Removing device #{name} (#{id})"
- `xcrun simctl delete #{id}`
- end
+ all_devices = `xcrun simctl list devices`
+ # == Devices ==
+ # -- iOS 9.0 --
+ # iPhone 4s (32246EBC-33B0-47F9-B7BB-5C23C550DF29) (Shutdown)
+ # iPhone 5 (4B56C101-6B95-43D1-9485-3FBA0E127FFA) (Shutdown)
+ # iPhone 5s (6379C204-E82A-4FBD-8A22-6A01C7791D62) (Shutdown)
+ # -- Unavailable: com.apple.CoreSimulator.SimRuntime.iOS-8-4 --
+ # iPhone 4s (FE9D6F85-1C51-4FE6-8597-FCAB5286B869) (Shutdown) (unavailable, runtime profile not found)
+
+ all_devices.split("\n").each do |line|
+ parsed = line.match(/\s+([\w\s]+)\s\(([\w\-]+)\)/) || []
+ next unless parsed.length == 3 # we don't care about those headers
+ parsed, name, id = parsed.to_a
+ puts "Removing device #{name} (#{id})"
+ `xcrun simctl delete #{id}`
end
+
+ all_device_types = `xcrun simctl list devicetypes`.scan(/(.*)\s\((.*)\)/)
+ # == Device Types ==
+ # iPhone 4s (com.apple.CoreSimulator.SimDeviceType.iPhone-4s)
+ # iPhone 5 (com.apple.CoreSimulator.SimDeviceType.iPhone-5)
+ # iPhone 5s (com.apple.CoreSimulator.SimDeviceType.iPhone-5s)
+ # iPhone 6 (com.apple.CoreSimulator.SimDeviceType.iPhone-6)
+ all_device_types.each do |device_type|
+ next if device_type.join(' ').include?"Watch" # we don't want to deal with the Watch right now
- # device_types
- # ["iPhone 5", "com.apple.CoreSimulator.SimDeviceType.iPhone-5"],
- # ["iPhone 5s", "com.apple.CoreSimulator.SimDeviceType.iPhone-5s"],
- # ["iPhone 6", "com.apple.CoreSimulator.SimDeviceType.iPhone-6"],
- device_types.each do |device_type|
- next if device_type.first.include?"Watch" # we don't want to deal with the Watch right now
-
puts "Creating #{device_type} for iOS version #{ios_version}"
- command = "xcrun simctl create '#{device_type[0]}' #{device_type[1]} #{ios_version}"
- command_output = `#{command}`
+ `xcrun simctl create '#{device_type[0]}' #{device_type[1]} #{ios_version}`
end
end
end
end
\ No newline at end of file