Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Show a menu to open the directory containing an iOS simulator app
#!/usr/bin/env python
import sys
import plistlib
import re
import os
import subprocess
def simulator_name(arg):
match = re.match("[\w\-\/]+/CoreSimulator/Devices/[0-9A-F\-]+/", arg)
device_dir = match.group()
device_plist = os.path.join(device_dir, "device.plist")
pl = plistlib.readPlist(device_plist)
version = pl["runtime"].split(".")[-1]
return pl['name'] + "/" + version
if __name__=='__main__':
base_dir = os.path.expanduser("~/Library/Developer/CoreSimulator/Devices")
r = subprocess.check_output('find ' + base_dir + ' -type d -depth 5 -name *.app', shell=True)
apps = r.strip().split("\n")
i = 1
for a in apps:
print str(i) + ") " + simulator_name(a) + "/" + a.split('/')[-1]
i += 1
choice = raw_input("open which app? (q to cancel): ")
try:
c = int(choice)
app_dir = apps[c - 1]
app_dir = os.path.dirname(app_dir)
print app_dir
subprocess.call("open " + app_dir, shell=True)
except Exception, e:
pass
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.