class Xcodeproj::XcodebuildHelper


Helper class which returns information from xcodebuild.

def self.instance

Returns:
  • (XcodebuildHelper) - the current xcodebuild instance creating one
def self.instance
  @instance ||= new
end

def initialize

def initialize
  @needs_to_parse_sdks = true
end

def last_ios_sdk

Returns:
  • (String) - The version of the last iOS sdk.
def last_ios_sdk
  parse_sdks_if_needed
  verions_by_sdk[:ios].sort.last
end

def last_osx_sdk

Returns:
  • (String) - The version of the last OS X sdk.
def last_osx_sdk
  parse_sdks_if_needed
  verions_by_sdk[:osx].sort.last
end

def parse_sdks_if_needed

Returns:
  • (void) - Parses the SDKs returned by xcodebuild and stores the
def parse_sdks_if_needed
  if @needs_to_parse_sdks
    @verions_by_sdk = {}
    @verions_by_sdk[:osx] = []
    @verions_by_sdk[:ios] = []
    if xcodebuild_available?
      skds = parse_sdks_information(xcodebuild_sdks)
      skds.each do |(name, version)|
        case
        when name == 'macosx' then @verions_by_sdk[:osx] << version
        when name == 'iphoneos' then @verions_by_sdk[:ios] << version
        end
      end
    end
  end
end

def parse_sdks_information(output)

Returns:
  • (Array>) - An array of tuples where the first element
def parse_sdks_information(output)
  output.scan(/-sdk (macosx|iphoneos)(.+\w)/)
end

def xcodebuild_available?

Returns:
  • (Bool) - Whether xcodebuild is available.
def xcodebuild_available?
  if @xcodebuild_available.nil?
    `which xcodebuild 2>/dev/null`
    @xcodebuild_available = $?.exitstatus.zero?
  end
  @xcodebuild_available
end

def xcodebuild_sdks

Returns:
  • (String) - The sdk information reported by xcodebuild.
def xcodebuild_sdks
  `xcodebuild -showsdks 2>/dev/null`
end