How can I reset the iOS Simulator from the command line? How can I reset the iOS Simulator from the command line? ios ios

How can I reset the iOS Simulator from the command line?


Just run this in the terminal:

xcrun simctl shutdown all && xcrun simctl erase all

Another approach suggested by @txulu, before erasing the simulator kill the process:

killall "Simulator" 2> /dev/null; xcrun simctl erase all


In Xcode 6, DO NOT JUST DELETE THE FOLDER FOR THE SIMULATOR! It WILL screw things up, and it WILL cause you a headache.

In Xcode 6, there's actually a tool to control the simulator from the command line.

Make sure your command line settings are set to Xcode 6

xcrun simctl

In Xcode 6, each device has a GUID/UUID associated to it, to reset a specific device, you need the GUID for it.

The command

xcrun simctl list

will show you all of the devices you have set up. The output will look like this:

== Devices ==-- iOS 7.0 --iPhone 4s (F77DC0AE-6A6D-4D99-9936-F9DB07BBAA82) (Shutdown)iPhone 5 (5B78FC0D-0034-4134-8B1F-19FD0EC9D581) (Shutdown)iPhone 5s (569E5910-E32D-40E2-811F-D2E8F04EA4EF) (Shutdown)iPad 2 (451DBBD8-A387-4E77-89BF-2B3CD45B4772) (Shutdown)iPad Retina (2C58366B-5B60-4687-8031-6C67383D793F) (Shutdown)iPad Air (50E03D3B-3456-4C49-85AD-60B3AFE4918B) (Shutdown)-- iOS 7.1 ---- iOS 8.0 --iPhone 4s (27818821-A0BB-496E-A956-EF876FB514C2) (Shutdown)iPhone 5 (6FBAA7E2-857C-432A-BD03-980D762DA9D2) (Shutdown)iPhone 5s (7675C82B-DE49-45EB-A28D-1175376AEEE9) (Shutdown)iPad 2 (836E7C89-B9D6-4CC5-86DE-B18BA8600E7B) (Shutdown)iPad Retina (EFDD043D-2725-47DC-A3FF-C984F839A631) (Shutdown)iPad Air (9079AD6C-E74D-4D5F-9A0F-4933498B852E) (Shutdown)Resizable iPhone (943CFEDE-A03C-4298-93E3-40D0713652CB) (Shutdown)Resizable iPad (DBA71CA5-6426-484B-8E9B-13FCB3B27DEB) (Shutdown)

Just copy the GUID from inside the parentheses, and run xcrun simctl erase

for example,

xcrun simctl erase 5B78FC0D-0034-4134-8B1F-19FD0EC9D581

would erase the iOS 7.0, iPhone 5 device


Thought I'd post this for anyone who runs into the same need. Someone on reddit gave me this solution (which I tested and it works great). Note that this time you need an ellipsis after "Settings", not three periods (weird).

This is an AppleScript that can be invoked from the command line to reset the Simulator:

tell application "iPhone Simulator"    activateend telltell application "System Events"    tell process "iPhone Simulator"        tell menu bar 1            tell menu bar item "iOs Simulator"                tell menu "iOs Simulator"                    click menu item "Reset Content and Settingsā€¦"                end tell            end tell        end tell        tell window 1            click button "Reset"        end tell    end tellend tell

Save as /path/to/script and invoke with:

osascript /path/to/script