-
-
Save ZevEisenberg/5a172662cb576872d1ab to your computer and use it in GitHub Desktop.
osascript -e 'tell application "iOS Simulator" to quit' | |
osascript -e 'tell application "Simulator" to quit' | |
xcrun simctl erase all |
Thank you so much
it worked
the amount of disk this freed up is astounding, thanks
hah, just found this again! like the updated version, so much cleaner!
I thought there was a problem with the database, turns out the simulator only needs resetting!
xcrun simctl erase all
This is amazing! Thanks a lot!
Based on the answer above, I improved the command:
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService; xcrun simctl list devices | grep "iPhone\|iPad" | awk '{print $(NF -1)}' | cut -d "(" -f2 | cut -d ")" -f1 | xargs -I {} xcrun simctl erase "{}"
The first part (sudo killall) will make sure that the simulator is closed, so there won't be any simulator in Booted or Creating state (which will throw an error on delete).
I changed the UDID retrieval, as for devices like "iPad (5th generation) (D88F16C6-AEF4-40BF-A8A5-0CA2FB548A9D) (Shutdown)" it would pick up the incorrect text. In my version, it will always pick up the second to last word, instead of the 3rd word.
Also, when I get devices, I filter only iPhone and iPad simulators. This gives a bit of flexibility.
I use this combination as a hard reset for all my simulators.
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 "{}"
?
this grep-cut trick does not work fun now. :Q
Based on the answer above, I improved the command:
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService; xcrun simctl list devices | grep "iPhone\|iPad" | awk '{print $(NF -1)}' | cut -d "(" -f2 | cut -d ")" -f1 | xargs -I {} xcrun simctl erase "{}"
The first part (sudo killall) will make sure that the simulator is closed, so there won't be any simulator in Booted or Creating state (which will throw an error on delete).
I changed the UDID retrieval, as for devices like "iPad (5th generation) (D88F16C6-AEF4-40BF-A8A5-0CA2FB548A9D) (Shutdown)" it would pick up the incorrect text. In my version, it will always pick up the second to last word, instead of the 3rd word.Also, when I get devices, I filter only iPhone and iPad simulators. This gives a bit of flexibility.
I use this combination as a hard reset for all my simulators.
This also does not work fun, so I make a fix. : )
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService; xcrun simctl list devices | grep "iPhone\|iPad" | awk '{print $(NF -1)}' | cut -d "(" -f2 | cut -d ")" -f1 | grep -E "^[0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12}$" | xargs -I {} xcrun simctl erase "{}"
I found this while looking to delete all simulators (instead of erase). If you want to do that, you can delete them all with xcrun simctl delete all
.
none of this stuff worked for me
# run this multiple times
pkill -flai xcode
# if any $process_id refuses to die and keeps printing out when doing the previous command, run this
kill -9 $process_id
🥳
In Xcode 9, you can use
xcrun simctl shutdown all
to shutdown the simulators.