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
# File 'lib/fastlane_core/simulator.rb', line 6

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

  # we do it using open since ` just randomly hangs with instruments -s
  output = ''
  Open3.popen3('instruments -s') do |stdin, stdout, stderr, wait_thr|
    output = stdout.read
  end

  unless output.include?("Known Devices")
    Helper.log.error "Instruments CLI broken, run `instruments -s` and make sure it works".red
    Helper.log.error "The easiest way to fix this is to restart your Mac".red
    raise "Instruments CLI not working.".red
  end

  output = output.split("Known Devices:").last.split("Known Templates:").first
  @devices = []
  output.split("\n").each do |current|
    m = current.match(/(.*) \((.*)\) \[(.*)\]/)
    next unless m
    name = m[1].to_s.strip
    ios = m[2].to_s.strip
    udid = m[3].to_s.strip
    next unless udid.include?("-") # as we want to ignore the real devices

    @devices << Device.new(name: name, ios_version: ios, udid: udid)
  end

  return @devices
end

.clear_cacheObject



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

def clear_cache
  @devices = nil
end