Created
March 6, 2024 17:34
-
-
Save dflems/85545920d7f29f0ffea5760231dbd443 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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