class Xcodeproj::XcodebuildHelper
Helper
class which returns information from xcodebuild.
Attributes
versions_by_sdk[RW]
@return [Hash] The versions of the sdks grouped by name (‘:ios`, or `:osx`).
Public Class Methods
instance()
click to toggle source
@return [XcodebuildHelper] the current xcodebuild instance creating one
if needed, which caches the information from the xcodebuild command line tool.
# File lib/xcodeproj/xcodebuild_helper.rb, line 111 def self.instance @instance ||= new end
new()
click to toggle source
# File lib/xcodeproj/xcodebuild_helper.rb, line 5 def initialize @needs_to_parse_sdks = true end
Public Instance Methods
last_ios_sdk()
click to toggle source
@return [String] The version of the last iOS sdk.
# File lib/xcodeproj/xcodebuild_helper.rb, line 11 def last_ios_sdk parse_sdks_if_needed versions_by_sdk[:ios].sort.last end
last_osx_sdk()
click to toggle source
@return [String] The version of the last OS X sdk.
# File lib/xcodeproj/xcodebuild_helper.rb, line 18 def last_osx_sdk parse_sdks_if_needed versions_by_sdk[:osx].sort.last end
last_tvos_sdk()
click to toggle source
@return [String] The version of the last tvOS sdk.
# File lib/xcodeproj/xcodebuild_helper.rb, line 25 def last_tvos_sdk parse_sdks_if_needed versions_by_sdk[:tvos].sort.last end
last_visionos_sdk()
click to toggle source
@return [String] The version of the last visionOS sdk.
# File lib/xcodeproj/xcodebuild_helper.rb, line 32 def last_visionos_sdk parse_sdks_if_needed versions_by_sdk[:visionos].sort.last end
last_watchos_sdk()
click to toggle source
@return [String] The version of the last watchOS sdk.
# File lib/xcodeproj/xcodebuild_helper.rb, line 39 def last_watchos_sdk parse_sdks_if_needed versions_by_sdk[:watchos].sort.last end
Private Instance Methods
parse_sdks_if_needed()
click to toggle source
@return [void] Parses the SDKs returned by xcodebuild and stores the
information in the `needs_to_parse_sdks` hash.
# File lib/xcodeproj/xcodebuild_helper.rb, line 57 def parse_sdks_if_needed if @needs_to_parse_sdks @versions_by_sdk = {} @versions_by_sdk[:osx] = [] @versions_by_sdk[:ios] = [] @versions_by_sdk[:tvos] = [] @versions_by_sdk[:visionos] = [] @versions_by_sdk[:watchos] = [] if xcodebuild_available? sdks = parse_sdks_information(xcodebuild_sdks) sdks.each do |(name, version)| case when name == 'macosx' then @versions_by_sdk[:osx] << version when name == 'iphoneos' then @versions_by_sdk[:ios] << version when name == 'appletvos' then @versions_by_sdk[:tvos] << version when name == 'xros' then @versions_by_sdk[:visionos] << version when name == 'watchos' then @versions_by_sdk[:watchos] << version end end end end end
parse_sdks_information(output)
click to toggle source
@return [Array<Array<String>>] An array of tuples where the first element
is the name of the SDK and the second is the version.
# File lib/xcodeproj/xcodebuild_helper.rb, line 93 def parse_sdks_information(output) output.scan(/-sdk (macosx|iphoneos|watchos|appletvos|xros)(.+\w)/) end
xcodebuild_available?()
click to toggle source
@return [Bool] Whether xcodebuild is available.
# File lib/xcodeproj/xcodebuild_helper.rb, line 82 def xcodebuild_available? if @xcodebuild_available.nil? `which xcodebuild 2>/dev/null` @xcodebuild_available = $?.exitstatus.zero? end @xcodebuild_available end
xcodebuild_sdks()
click to toggle source
@return [String] The sdk information reported by xcodebuild.
# File lib/xcodeproj/xcodebuild_helper.rb, line 99 def xcodebuild_sdks `xcodebuild -showsdks 2>/dev/null` end