Skip to content

Instantly share code, notes, and snippets.

@pudquick pudquick/
Last active Apr 8, 2018

What would you like to do?
Programmatically load detailed version information about Xcode version via pyobjc on macOS
# Warning - because of how this works, it loads classes into memory namespace.
# Attempting to load a second Xcode to inspect within the same python run will result in errors
# If you need to inspect multiple, for now, just spin the inspection up under a second process
from Foundation import NSBundle
def xcode_info(app_path):
# app_path = '/Applications/'
DVTFoundation = NSBundle.bundleWithPath_('%s/Contents/SharedFrameworks/DVTFoundation.framework' % app_path)
IDEKit = NSBundle.bundleWithPath_('%s/Contents/Frameworks/IDEKit.framework' % app_path)
DVTToolsInfo = DVTFoundation.classNamed_('DVTToolsInfo')
x_info = DVTToolsInfo.toolsInfo()
x_v = x_info.toolsVersion()
x_b = x_info.toolsBuildVersion()
d = dict()
d['name'] =
d['major'] = x_v.versionMajorComponent()
d['minor'] = x_v.versionMinorComponent()
d['update'] = x_v.versionUpdateComponent()
d['build'] =
d['is_beta'] = x_info.isBeta()
d['beta_version'] = 0
if d['is_beta']:
d['beta_version'] = x_info.toolsBetaVersion()
beta_str = ''
if d['is_beta']:
beta_str = 'beta '
if d['beta_version'] >= 2:
beta_str = 'beta %s ' % (d['beta_version'])
d['display'] = '%s %s(%s)' % (d['name'], beta_str, d['build'])
return d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.