Xcode Space Clean-Up
Free up space on your Mac by deleting excessive support files
This script is used to clean up the support files for building apps for each version of iOS and WatchOS on each device you have plugged in with Xcode open. Each set of files can be multiple gigabytes. This script can help free up dozens of gigabytes of storage.
Scenarios to use this script:
- Attempting to update Xcode and you receive the error:
There is not enough disk space to install this product.
- You have deleted Xcode in hopes it would create enough space to install it again.
- You need more space on your Loop-building computer and know you haven’t done this in a long time (or at all).
This script also includes deleting carthage and derived data files that can take up space and cause problems when building. These commands can be found in the Clean-Cart-Derived script page.
As of Xcode 12.2, it no longer auto downloads the support files (simulators). If you delete them without doing a full new Xcode install, you must manually download the ones you need.
- You might be required to fully uninstall and reinstall Xcode after running this script.
- As of Xcode 12.2, the support files (simulators) no longer auto download. If you delete them without doing a full new Xcode install, you must manually download the ones you need.
- Do not run this if you are offline and expect to build. You will not be able to build for your device until Xcode downloads the necessary support files for your device.
- Plug in your phone
- Connect to the Internet
- Xcode will download the support files for your device(s) and iOS version.
If you are not uninstalling and re-installing Xcode, you probably want this cleanup script instead. Clean-Cart-Derived
Run Xcode Code Clean-up
- If Xcode is open, you must close it before running this script.
- Open Terminal
- Copy/Paste this code into Terminal all on one line and hit ENTER:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/loopnlearn/LoopBuildScripts/main/XcodeClean.sh)"
To see the commands, look at this link:
Alternatively, you can copy/paste each of the four individual “rm” commands, found in GitHub in the link above, into a terminal instead of running this script if you prefer.
Need Even More Space?
To clean up even more Xcode files, click on the Apple symbol in the upper left corner of your screen, then click on About This Mac/Storage/Manage, and highlight and then delete all but the most recent support files. Here are the “before” and “after” clean-up screenshots. There’s no need to worry if you delete too many support files, simply re-download Xcode.