Method: Snapshot::TestCommandGenerator.destination

Defined in:
snapshot/lib/snapshot/test_command_generator.rb

.destination(devices) ⇒ Object


35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'snapshot/lib/snapshot/test_command_generator.rb', line 35

def destination(devices)
  unless verify_devices_share_os(devices)
    UI.user_error!('All devices provided to snapshot should run the same operating system')
  end
  # on Mac we will always run on host machine, so should specify only platform
  return ["-destination 'platform=macOS'"] if devices.first.to_s =~ /^Mac/

  os = devices.first.to_s =~ /^Apple TV/ ? "tvOS" : "iOS"

  os_version = Snapshot.config[:ios_version] || Snapshot::LatestOsVersion.version(os)

  destinations = devices.map do |d|
    device = find_device(d, os_version)
    if device.nil?
      UI.user_error!("No device found named '#{d}' for version '#{os_version}'") if device.nil?
    elsif device.os_version != os_version
      UI.important("Using device named '#{device.name}' with version '#{device.os_version}' because no match was found for version '#{os_version}'")
    end
    "-destination 'platform=#{os} Simulator,name=#{device.name},OS=#{device.os_version}'"
  end

  return [destinations.join(' ')]
end