Create a gist now

Instantly share code, notes, and snippets.

Embed
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
@armcknight

This comment has been minimized.

Show comment
Hide comment
@armcknight

armcknight Sep 27, 2014

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 "{}"?

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 "{}"?

@ZevEisenberg

This comment has been minimized.

Show comment
Hide comment
@ZevEisenberg

ZevEisenberg Sep 27, 2014

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

Owner

ZevEisenberg commented Sep 27, 2014

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

@Sarkazein

This comment has been minimized.

Show comment
Hide comment
@Sarkazein

Sarkazein Oct 7, 2014

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

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

@mattneub

This comment has been minimized.

Show comment
Hide comment
@mattneub

mattneub Jan 28, 2015

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

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

@ArtSabintsev

This comment has been minimized.

Show comment
Hide comment
@ArtSabintsev

ArtSabintsev Jan 29, 2015

This is awesome - thanks, @ZevEisenberg and @sixstringtheory

This is awesome - thanks, @ZevEisenberg and @sixstringtheory

@vittoriom

This comment has been minimized.

Show comment
Hide comment
@vittoriom

vittoriom Aug 20, 2015

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

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

@capnslipp

This comment has been minimized.

Show comment
Hide comment
@capnslipp

capnslipp Oct 21, 2015

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 …/Xcode.app/…/simctl, but when given simctl erase --all calls your code instead. ;-)

So… much cheers.

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 …/Xcode.app/…/simctl, but when given simctl erase --all calls your code instead. ;-)

So… much cheers.

@Blackjacx

This comment has been minimized.

Show comment
Hide comment
@Blackjacx

Blackjacx Nov 10, 2015

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

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

@ZevEisenberg

This comment has been minimized.

Show comment
Hide comment
@ZevEisenberg

ZevEisenberg Dec 16, 2015

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

Owner

ZevEisenberg commented Dec 16, 2015

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

@stanislaw

This comment has been minimized.

Show comment
Hide comment
@stanislaw

stanislaw Aug 26, 2016

Very useful, thanks!

Very useful, thanks!

@jeanmw

This comment has been minimized.

Show comment
Hide comment
@jeanmw

jeanmw May 16, 2017

Yay, thanks so much this is super useful/convenient for testing!

jeanmw commented May 16, 2017

Yay, thanks so much this is super useful/convenient for testing!

@neilt

This comment has been minimized.

Show comment
Hide comment
@neilt

neilt Sep 25, 2017

In Xcode 9, you can use xcrun simctl shutdown all to shutdown the simulators.

neilt commented Sep 25, 2017

In Xcode 9, you can use xcrun simctl shutdown all to shutdown the simulators.

@SupriyaKalghatgi

This comment has been minimized.

Show comment
Hide comment
@SupriyaKalghatgi

SupriyaKalghatgi Nov 13, 2017

Thank you so much
it worked

Thank you so much
it worked

@sampurcell93

This comment has been minimized.

Show comment
Hide comment
@sampurcell93

sampurcell93 Dec 20, 2017

the amount of disk this freed up is astounding, thanks

the amount of disk this freed up is astounding, thanks

@armcknight

This comment has been minimized.

Show comment
Hide comment
@armcknight

armcknight May 15, 2018

hah, just found this again! like the updated version, so much cleaner!

hah, just found this again! like the updated version, so much cleaner!

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