Skip to content

Instantly share code, notes, and snippets.

@dflems
Created March 6, 2024 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dflems/85545920d7f29f0ffea5760231dbd443 to your computer and use it in GitHub Desktop.
Save dflems/85545920d7f29f0ffea5760231dbd443 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
# Delete existing simulators and recreate simulators for compatible runtimes.
import json
import os
import subprocess
def main():
# Delete all devices
device_udids = []
for _, dl in list(simctl_json("devices").items()):
for dev in dl:
udid = dev["udid"]
print(f"Deleting Simulator: {udid}")
subprocess.call(["xcrun", "simctl", "delete", udid])
# Loop through and recreate
for rt in simctl_json("runtimes"):
if not rt["isAvailable"]:
continue
rt_ident = rt["identifier"]
for dt in rt["supportedDeviceTypes"]:
dt_ident = dt["identifier"]
dt_name = dt["name"]
print(f"Creating {dt_name} ({rt_ident})")
subprocess.call([
"xcrun", "simctl", "create", dt_name, dt_ident, rt_ident])
def simctl_json(t):
return json.loads(
subprocess.check_output(f"xcrun simctl list {t} -j" , shell=True))[t]
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment