Is there any option to reset the contents and settings of all the simulators ?In a single event or a single command via command line?
14 Answers
Based on the the answer from Jeremy Huddleston Sequoia I wrote a shell script that will reset all simulators.
For Xcode 7 you can use:
#!/bin/sh
instruments -s devices \
| grep "(\d[.0-9]\+) \[[0-9A-F]\{8\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{12\}\]" \
| grep -o "[0-9A-F]\{8\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{12\}" \
| while read -r line ; do
echo "Reseting Simulator with UDID: $line"
xcrun simctl erase $line
done
For previous versions use:
#!/bin/sh
instruments -s devices \
| grep Simulator \
| grep -o "[0-9A-F]\{8\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{12\}" \
| while read -r line ; do
echo "Reseting Simulator with UDID: $line"
xcrun simctl erase $line
done

- 4,487
- 3
- 38
- 36
-
You forgot a `"` Character at the end of your regex. Can't edit for one character, so I'm just commenting :) – Rémy Virin Oct 23 '14 at 08:14
-
Hi Daniel. This worked flawlessly, but it stopped working for xcode7. I think you need to change the regex – eertl Sep 18 '15 at 11:57
With Xcode 6, you can use the simctl command line utility:
xcrun simctl erase <device UDID>
With Xcode 7, you can erase all at once with:
xcrun simctl erase all

- 22,938
- 5
- 78
- 86
-
1To anyone reading these answers, I will say that this is definitely a better option than simply whacking the application support iPhone Simulator folder with rm -rf. – Mark Edington Jun 14 '15 at 19:23
With Xcode 10:
#!/usr/bin/env sh
xcrun simctl shutdown all
xcrun simctl erase all

- 31,030
- 13
- 103
- 118
I present,
The Definitive iOS Simulator Reset Script (link)
Based on Oded Regev's code from this SO question (which was based on Jacob Rus's fine "menu_click" code)

- 1
- 1

- 3,625
- 2
- 27
- 32
-
2
-
1Thanks, thats very useful indeed. But unfortunately its not working for me. (XCode 4.6.1) – ytpm Mar 28 '13 at 10:02
-
Yossi, use Github Issues to document bugs and request fixes. I'm more than happy to help you, but please use Github Issues for further communication. – Stian Høiland Mar 28 '13 at 17:22
Inspired by the answer from Daniel Wood, I came up with this one.
It solves the problem of what to do with a running simulator. Our CI environment leaves the simulator running after the tests run, and that's getting more tainted over time.
The guid detection isn't as accurate, but I think the readability trade-off is worthwhile.
#!/bin/bash
xcrun simctl list | grep Booted | grep -e "[0-9A-F\-]\{36\}" -o | xargs xcrun simctl shutdown
xcrun simctl erase all
Tested with the XCode 7.

- 521
- 6
- 8
-
awesome, I didn't know there was a xcrun 'shutdown' argument. Thanks. – Laser Hawk Dec 07 '15 at 17:21
-
This should probably be the new accepted answer. Let's retire The Definitive iOS Simulator Reset Script ;) – Stian Høiland Aug 22 '16 at 18:55
With the latest version of Xcode command line tools you can call xcrun simctl erase all
Make sure to quit the sim every time you call this function or you'll get an error stating An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=159):
Unable to erase contents and settings in current state: Booted

- 1,988
- 2
- 23
- 29
-
This works on both Xcode 6 and 7 and is much simpler than any 3rd party script. – leolobato Dec 06 '15 at 16:45
-
1
you can run this command
xcrun simctl erase all

- 4,554
- 4
- 33
- 46
-
1Actaully, that very much does provide the exact answer to the question. – Jeremy Huddleston Sequoia Oct 21 '16 at 23:40
Simply go to ~/Library/Application Support/iPhone Simulator
and delete all the contents out of there. The above methods don't work on iOS 7, so this seemed to work for me.

- 4,809
- 6
- 33
- 45
I wrote a script that will reset the contents & settings of all versions and devices for the iOS Simulator. It grabs the device names and version numbers from the menu, so it will include any new devices or iOS versions that Apple releases simulators for.
It's easy to run manually or use in a build-script. I would suggest adding it as a Pre-Action Run Script before the build.
It's based heavily on Stian's script above, but doesn't become stale with new iOS versions, and eliminates the dialog box (better for automation build scripts).

- 4,909
- 3
- 25
- 31
1) Quit from all simulators
2) Run below command in terminal
xcrun simctl erase all

- 63
- 7
There is a tool xctool - https://github.com/facebook/xctool which is replacement of xcodebuild. It allows to build application from command line as well as run tests for it. Besides running tests it is allows to provide arguments such as -freshSimulator and -freshInstall that resetting content for target simulator before executing tests. That simplifies a lot resetting of simulator, as you avoiding various magic with bash scripts etc everything encapsulated within tool.

- 5,684
- 31
- 37
To set the user content and settings of the simulator to their factory state and remove the applications you have installed, choose iPhone Simulator > Reset Content and Settings.

- 40,222
- 21
- 149
- 183
-
1this only resets one. he didnt ask that :) he asked to reset multiple at once! – Daij-Djan Mar 13 '13 at 08:44
-
So he cannot do it directly. one could write a bash schript / apple script to directly modify the filesystem.... all the sims are under ~/Library/Application Support/iPhone Simulator/%VERSION% – Daij-Djan Mar 13 '13 at 08:45
You can call this command:
rm -rf ~/Library/Application Support/iPhone Simulator

- 4,601
- 3
- 23
- 42

- 169
- 2
- 9