A small, dependency-free cleanup guard for Xcode development machines.
It reports Xcode storage without changing anything by default. Destructive
actions require both --apply and an explicit category. The script never
touches archives, provisioning profiles, app containers, recovery copies, or
physical-device support.
Xcode can quietly accumulate DerivedData and several multi-gigabyte simulator devices. This tool was extracted after a real cleanup recovered about 22 GB while preserving the one iPhone simulator, one Watch simulator, current device support, signing profiles, and application data that were still useful.
./xcode-hygiene.shPreview a specific cleanup:
./xcode-hygiene.sh \
--clean-derived-data \
--delete-unavailable-simulators \
--prune-simulators \
--keep-simulator "iPhone 17" \
--keep-simulator "Apple Watch Series 11 (46mm)"The second command still changes nothing. It prints the devices that would be deleted.
Run the same command with --apply only after reviewing the preview:
./xcode-hygiene.sh \
--apply \
--clean-derived-data \
--delete-unavailable-simulators \
--prune-simulators \
--keep-simulator "iPhone 17" \
--keep-simulator "Apple Watch Series 11 (46mm)"The script refuses to continue while xcodebuild or an XCTest runner is
active. Simulator pruning also refuses to run unless every requested keep-name
exists in the current device set.
Archives: these may be the only reproducible signed release artifacts.Provisioning Profiles: deleting them can break local-device installation.iOS DeviceSupport: verify the physical device OS before deleting an older support directory.- Simulator app data you did not explicitly prune.
- Project directories, backups, and app containers.
./tests/test.shRequires macOS, Xcode command-line tools, Zsh, and the system Python 3 shipped with Xcode.
MIT