parameters: ()
return_statement: return XCODE_VERSION_CACHE
docstring: Returns a tuple of version and build version of installed Xcode.
docstring_summary: Returns a tuple of version and build version of installed Xcode.
docstring_tokens: Returns a tuple of version and build version of installed Xcode .
function: def XcodeVersion():
    """Returns a tuple of version and build version of installed Xcode."""
    # `xcodebuild -version` output looks like
    #    Xcode 4.6.3
    #    Build version 4H1503
    # or like
    #    Xcode 3.2.6
    #    Component versions: DevToolsCore-1809.0; DevToolsSupport-1806.0
    #    BuildVersion: 10M2518
    # Convert that to '0463', '4H1503'.
    global XCODE_VERSION_CACHE
    if XCODE_VERSION_CACHE:
      return XCODE_VERSION_CACHE
    try:
      version_list = GetStdout(['xcodebuild', '-version']).splitlines()
      # In some circumstances xcodebuild exits 0 but doesn't return
      # the right results; for example, a user on 10.7 or 10.8 with
      # a bogus path set via xcode-select
      # In that case this may be a CLT-only install so fall back to
      # checking that version.
      if len(version_list) < 2:
        raise GypError("xcodebuild returned unexpected results")
    except:
      version = CLTVersion()
      if version:
        version = re.match(r'(\d\.\d\.?\d*)', version).groups()[0]
      else:
        raise GypError("No Xcode or CLT version detected!")
      # The CLT has no build information, so we return an empty string.
      version_list = [version, '']
    version = version_list[0]
    build = version_list[-1]
    # Be careful to convert "4.2" to "0420":
    version = version.split()[-1].replace('.', '')
    version = (version + '0' * (3 - len(version))).zfill(4)
    if build:
      build = build.split()[-1]
    XCODE_VERSION_CACHE = (version, build)
    return XCODE_VERSION_CACHE
function_tokens: def XcodeVersion ( ) : # `xcodebuild -version` output looks like #    Xcode 4.6.3 #    Build version 4H1503 # or like #    Xcode 3.2.6 #    Component versions: DevToolsCore-1809.0; DevToolsSupport-1806.0 #    BuildVersion: 10M2518 # Convert that to '0463', '4H1503'. global XCODE_VERSION_CACHE if XCODE_VERSION_CACHE : return XCODE_VERSION_CACHE try : version_list = GetStdout ( [ 'xcodebuild' , '-version' ] ) . splitlines ( ) # In some circumstances xcodebuild exits 0 but doesn't return # the right results; for example, a user on 10.7 or 10.8 with # a bogus path set via xcode-select # In that case this may be a CLT-only install so fall back to # checking that version. if len ( version_list ) < 2 : raise GypError ( "xcodebuild returned unexpected results" ) except : version = CLTVersion ( ) if version : version = re . match ( r'(\d\.\d\.?\d*)' , version ) . groups ( ) [ 0 ] else : raise GypError ( "No Xcode or CLT version detected!" ) # The CLT has no build information, so we return an empty string. version_list = [ version , '' ] version = version_list [ 0 ] build = version_list [ - 1 ] # Be careful to convert "4.2" to "0420": version = version . split ( ) [ - 1 ] . replace ( '.' , '' ) version = ( version + '0' * ( 3 - len ( version ) ) ) . zfill ( 4 ) if build : build = build . split ( ) [ - 1 ] XCODE_VERSION_CACHE = ( version , build ) return XCODE_VERSION_CACHE