Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Helps for developing scripts that need to know the actual SDK path.
#!/usr/bin/python
import plistlib
import os
import commands
import argparse
DEVELOPER_DIR = commands.getoutput('/usr/bin/xcode-select -print-path')
PLATFORMS_DIRECTORY = os.path.join(DEVELOPER_DIR, "Platforms")
IPHONE_PLATFORM = "iPhoneOS.platform"
SIMULATOR_PLATFORM = "iPhoneSimulator.platform"
PLIST_FILE = "Info.plist"
def find_version(platform):
path = None
if (platform == 'iphoneos'):
path = os.path.join(PLATFORMS_DIRECTORY, IPHONE_PLATFORM, PLIST_FILE)
elif (platform == 'iphonesimulator'):
path = os.path.join(PLATFORMS_DIRECTORY, SIMULATOR_PLATFORM, PLIST_FILE)
else:
return None
version = plistlib.readPlist(path).CFBundleShortVersionString
return version
def get_sdk_path(platform, version):
path = None
if (platform == 'iphoneos'):
path = os.path.join(PLATFORMS_DIRECTORY, IPHONE_PLATFORM, "Developer", "SDKs", "iPhoneOS{0}.sdk".format(version))
elif (platform == 'iphonesimulator'):
path = os.path.join(PLATFORMS_DIRECTORY, SIMULATOR_PLATFORM, "Developer", "SDKs", "iPhoneSimulator{0}.sdk".format(version))
else:
return None
return path
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Returns the version of the currently installed platform sdk.')
parser.add_argument('-iphoneos', action='store_const', dest='platform', const='iphoneos')
parser.add_argument('-iphonesimulator', action='store_const', dest='platform', const='iphonesimulator')
parser.add_argument('-path', action='store_true', dest='showPath', default=False)
args = parser.parse_args()
if args.platform is None:
parser.print_help()
exit(0)
version = find_version(args.platform)
if (args.showPath):
print get_sdk_path(args.platform, version)
else:
print version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.