Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
DERIVED_DATA=~/Library/Developer/Xcode/DerivedData
# Kill Xcode
echo "💥 Killing Xcode ..."
kill $(ps aux | grep 'Xcode' | awk '{print $2}') 2>/dev/null
# Remove xcuserdata
for f in `ls -t $DERIVED_DATA`; do
plist=$DERIVED_DATA/$f/info.plist
if [ -e "$plist" ]; then
proj=`/usr/libexec/PlistBuddy -c "print :WorkspacePath" "$plist"`
echo " ↳ Cleaning project data: $proj ..."
find $proj -type d -name "xcuserdata" -exec rm -r {} +
break
fi
done
# Remove DerivedData
echo " ↳ Removing DerivedData ..."
rm -rf ~/Library/Developer/Xcode/DerivedData/*
# Relaunch Xcode
echo " ↳ Launching Xcode ..."
open -a Xcode
echo "🎉 Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment