Xcode nuclear option

Xcode nuclear option

If you’ve ever had a bizarre problem in Xcode and you’ve given up hope, this post is for you. Some frustrating things you might see:

  • Breakpoints stop working
  • A framework or library can’t be found that the compiler found moments ago
  • Symbols in linked frameworks are no longer found
  • This is not a comprehensive list.

I wrote this script a decade ago and in this frustrating moments, I run it, and go get a refreshing beverage while my computer reboots. It’s kind of unbelievable how often this has saved me. Maybe it will help you at least once in your life.

Note: Read the script first as it deletes your caches and DerivedData folder. It shouldn’t be a problem but you should be aware what it’s doing.

#!/bin/zsh

rm -rf ~/Library/Developer/Xcode/DerivedData

#edit this to point to your DerivedData folder
rm -rf ~/Library/Caches/*Xcode*

sudo find /var/folders -iname xcode -exec mv \{\} \{\}.saved \;
echo "Reboot is recommended!\n"