Sha256: 7ecc749923d1e1f10010321c6aed5b821419250761ad71f5938082100b5e624b

Contents?: true

Size: 1.35 KB

Versions: 8

Compression:

Stored size: 1.35 KB

Contents

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
      end

      device_types.each do |device_type|
        puts "Creating #{device_type} for iOS version #{ios_version}"
        command = "xcrun simctl create '#{device_type[0]}' #{device_type[1]} #{ios_version}"
        command_output = `#{command}`
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
snapshot-0.9.1 lib/snapshot/reset_simulators.rb
snapshot-0.9.0 lib/snapshot/reset_simulators.rb
snapshot-0.8.0 lib/snapshot/reset_simulators.rb
snapshot-0.7.1 lib/snapshot/reset_simulators.rb
snapshot-0.7.0 lib/snapshot/reset_simulators.rb
snapshot-0.6.1 lib/snapshot/reset_simulators.rb
snapshot-0.6.0 lib/snapshot/reset_simulators.rb
snapshot-0.5.0 lib/snapshot/reset_simulators.rb