Class: Snapshot::LatestOsVersion

Inherits:
Object
  • Object
show all
Defined in:
snapshot/lib/snapshot/latest_os_version.rb

Class Method Summary collapse

Class Method Details

.ios_versionObject



6
7
8
9
# File 'snapshot/lib/snapshot/latest_os_version.rb', line 6

def self.ios_version
  return ENV["SNAPSHOT_IOS_VERSION"] if FastlaneCore::Env.truthy?("SNAPSHOT_IOS_VERSION")
  self.version("iOS")
end

.version(os) ⇒ Object



12
13
14
# File 'snapshot/lib/snapshot/latest_os_version.rb', line 12

def self.version(os)
  @versions[os] ||= version_for_os(os)
end

.version_for_os(os) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'snapshot/lib/snapshot/latest_os_version.rb', line 16

def self.version_for_os(os)
  # We do all this, because we would get all kind of crap output generated by xcodebuild
  # so we need to ignore stderror
  output = ''
  Open3.popen3('xcodebuild -version -sdk') do |stdin, stdout, stderr, wait_thr|
    output = stdout.read
  end

  matched = output.match(/#{os} ([\d\.]+) \(.*/)
  if matched.nil?
    FastlaneCore::UI.user_error!("Could not determine installed #{os} SDK version. Try running the _xcodebuild_ command manually to ensure it works.")
  elsif matched.length > 1
    return matched[1]
  else
    FastlaneCore::UI.user_error!("Could not determine installed #{os} SDK version. Please pass it via the environment variable 'SNAPSHOT_IOS_VERSION'")
  end
end