Tips - How to clean your mac as an iOS developer?

Thân Đặng
2 min readJun 5, 2020

As an iOS developer, we’re almost familiar with Xcode, simulator. Especially Derived data capacity is increasing day by day. One day, your mac is freeze just because no space left on your disk. Here are some tips to clean up:

  1. Clean up your Derived folder: Whenever you combine, make a build from Xcode action, it will allocated all bundles and memory to DerivedData folder as an unique identifier (App), then it won’t be automatically deleted until we make clean up action from Xcode (Cmd+K).
    Your Derived is located at:
    ~/Library/Developer/Xcode/DerivedData/
  2. Clean up caching files: Cache files are located in any places that have in and output, but I prefer two places to clean up:
    ~/Library/Caches/
    ~/Library/Developer/CoreSimulator/Caches/
  3. Clean up Archive folder: Archive folder contains all Archive you has done in order to export IPA file or upload to AppStoreConnect. It locates in folder: ~/Library/Developer/Xcode/Archives/
  4. Empty trash.
  5. Delete old iOS DeviceSupport: Xcode, Swift, and iOS version changes too fast and we have to adapt to upgrade them. One of the challenge is we have to keep old iOS version which contains downloaded simulators to make sure our app is still stable. By time, the old devices are no longer needed. For example: we’re almost on iOS 10+ now and we don’t need iOS 9. Since we’re in iOS 13 and some of iOS 10 and iOS 11 won’t needed, we just need keep one: iOS 10.1 and iOS 11.1 for example. It will save us a lot of disk space. I prefer to manually delete from here. The iOS DeviceSupport is located here:
    ~/Library/Developer/Xcode/iOS\ DeviceSupport/

Here is the script I wrote as shortcut. Try to copy and run from your terminal.

rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Developer/Xcode/Archives/*
rm -rf ~/Library/Caches/*
rm -rf ~/.Trash/*
rm -rf ~/Library/Developer/CoreSimulator/Caches/*

It’s popular things but probably someone is new with it or not fully clean up your mac. Let give a try :)

You could find the source here: cleanup.sh

--

--