How to Clear Derived Data using Xcode Keyboard Shortcut?

Do you know, you can clear derived data from Xcode with a custom keyboard shortcut? First, Create a new script file somewhere in your system with following command -

rm -rf ~/Library/Developer/Xcode/DerivedData
rm -frd ~/Library/Caches/com.apple.dt.Xcode/*

Now, open terminal and run chmod +x Script.sh to make the file executable. Now go to Xcode's Preferences and select the Behaviors tab. Click on the + sign to add a new custom behavior, and on the right hand side, check Run and choose the script that was just created.

Click the symbol next to the behavior script name to set the keyboard shortcut. I use + + D for opening the Terminal. (Keyboard shortcut symbols - = Command key, = Control key, = Option (alt) key, = Shift key)

Here the demo video which cover all steps for similar script -


You've successfully subscribed to Developer Insider
Great! Next, complete checkout for full access to Developer Insider
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.