From 3f3dc5845f8d53c079261accd70946188f70e536 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Fri, 5 Apr 2024 16:01:42 +1100 Subject: [PATCH] Shutting down simulators before deleting (if they are running) --- Scripts/clean-up-old-test-simulators.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Scripts/clean-up-old-test-simulators.sh b/Scripts/clean-up-old-test-simulators.sh index eed8394f3..e1fd8b642 100755 --- a/Scripts/clean-up-old-test-simulators.sh +++ b/Scripts/clean-up-old-test-simulators.sh @@ -26,6 +26,7 @@ xcrun simctl delete unavailable # Extract all UUIDs from the device_set uuids=$(grep -Eo '[A-F0-9]{8}-([A-F0-9]{4}-){3}[A-F0-9]{12}' "$plist") +running_uuids=$(xcrun simctl list devices | grep -Eo '[A-F0-9]{8}-([A-F0-9]{4}-){3}[A-F0-9]{12}' | grep -v 'Shutdown') # Create empty arrays to store the outputs uuids_to_leave=() @@ -50,6 +51,11 @@ if [ ${#uuids_to_remove[@]} -eq 0 ]; then else echo -e "\e[31mDeleting ${#uuids_to_remove[@]} old test Simulators:\e[0m" for uuid in "${uuids_to_remove[@]}"; do + if echo "$running_uuids" | grep -q "$uuid"; then + echo "UUID is in running_uuids - shutting down" + xcrun simctl shutdown "$uuid" + fi + echo -e "\e[31m $uuid\e[0m" # xcrun simctl delete "$uuid" done