Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Reset all iOS simulators with this one weird trick
osascript -e 'tell application "iOS Simulator" to quit'
osascript -e 'tell application "Simulator" to quit'
xcrun simctl erase all

pretty good, but what about this one liner without the variable: xcrun simctl list devices | grep -v '^[-=]' | cut -d "(" -f2 | cut -d ")" -f1 | xargs -I {} xcrun simctl erase "{}"?


Nice. I couldn’t figure out how to do it because I have not the shell fu.


Man, I just spent an hour or two putting something like this together. This is so much simpler.


sixstringtheory I'd like to quote this in my book; may I?


This is awesome - thanks, @zeveisenberg and @sixstringtheory


I think it would be even better to pipe another grep like grep -v 'unavailable' after the first one. Otherwise the output will contain also unavailable devices that doesn't make sense to reset


That's so f'ing handy.

About the only way I can think of improving this is to make a wrapper simctl that normally calls the real …/…/simctl, but when given simctl erase --all calls your code instead. ;-)

So… much cheers.


Since Xcode 7 it is possible to do xcrun simctl erase all and combined with your osascript -e 'tell application "iOS Simulator" to quit' this is perfect for putting it inside the before integration trigger of a Xcode bot


Thanks, @blackjacx! Updated with the new first-party method of doing this.


Very useful, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment