Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
List all unprefixed Objective-C classes for a given SDK
#!/usr/bin/env python
import argparse, os, re, subprocess
parser = argparse.ArgumentParser()
parser.add_argument('--sdk', default='', help='OS X or iOS SDK directory')
parser.add_argument('--no-frameworks', action='store_true', default=False, help='do not print frameworks, only unprefixed classes')
args = parser.parse_args()
print_frameworks = not args.no_frameworks
frameworks = set()
for frameworkDir in ['Frameworks', 'PrivateFrameworks']:
for root, dirs, files in os.walk(os.path.join(args.sdk + '/System/Library', frameworkDir)):
base, extension = os.path.splitext(os.path.basename(root))
if extension != '.framework':
framework = root + '/' + base
nm = subprocess.Popen(['nm', '-U', framework], stdout = subprocess.PIPE, stderr = subprocess.PIPE)
while True:
line = nm.stdout.readline()
if len(line) == 0:
match =' S _OBJC_CLASS_\$_(.*)', line)
if match == None:
className =
if re.match(r'^[A-Z][a-z]', className) and not className.startswith(base):
if print_frameworks and not framework in frameworks:
print framework
print '%s%s' % (' ' if print_frameworks else '', className)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment