Class: Snapshot::LatestIosVersion

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

Class Method Summary collapse

Class Method Details

.versionObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/snapshot/latest_ios_version.rb', line 4

def self.version
  return ENV["SNAPSHOT_IOS_VERSION"] if ENV["SNAPSHOT_IOS_VERSION"]
  return @version if @version

  # 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(/iOS ([\d\.]+) \(.*/)
  if matched.nil?
    raise "Could not determine installed iOS SDK version. Try running the _xcodebuild_ command manually to ensure it works."
  elsif matched.length > 1
    return @version ||= matched[1]
  else
    raise "Could not determine installed iOS SDK version. Please pass it via the environment variable 'SNAPSHOT_IOS_VERSION'".red
  end
end