Class: FastlaneCore::Simulator

Inherits:
Object
  • Object
show all
Defined in:
lib/fastlane_core/simulator.rb

Defined Under Namespace

Classes: Device

Class Method Summary collapse

Class Method Details

.allObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fastlane_core/simulator.rb', line 6

def all
  Helper.log.info "Fetching available devices" if $verbose

  @devices = []
  os_type = 'unknown'
  os_version = 'unknown'
  output = ''
  Open3.popen3('xcrun simctl list devices') do |stdin, stdout, stderr, wait_thr|
    output = stdout.read
  end

  unless output.include?("== Devices ==")
    Helper.log.error "xcrun simctl CLI broken, run `xcrun simctl list devices` and make sure it works".red
    raise "xcrun simctl not working.".red
  end

  output.split(/\n/).each do |line|
    next if line.match(/^== /)
    if line.match(/^-- /)
      (os_type, os_version) = line.gsub(/-- (.*) --/, '\1').split
    else
      # iPad 2 (0EDE6AFC-3767-425A-9658-AAA30A60F212) (Shutdown)
      # iPad Air 2 (4F3B8059-03FD-4D72-99C0-6E9BBEE2A9CE) (Shutdown) (unavailable, device type profile not found)
      match = line.match(/\s+([^\(]+) \(([-0-9A-F]+)\) \((?:[^\(]+)\)(.*unavailable.*)?/)
      if match && !match[3] && os_type == 'iOS'
        @devices << Device.new(name: match[1], ios_version: os_version, udid: match[2])
      end
    end
  end

  return @devices
end

.clear_cacheObject



39
40
41
# File 'lib/fastlane_core/simulator.rb', line 39

def clear_cache
  @devices = nil
end