Skip to content

Instantly share code, notes, and snippets.

@ekreutz
Forked from maciekish/resetXcode.sh
Last active February 28, 2018 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ekreutz/b245da335cc10b0d270136b35eb22d1f to your computer and use it in GitHub Desktop.
Save ekreutz/b245da335cc10b0d270136b35eb22d1f to your computer and use it in GitHub Desktop.
Reset Xcode. Clean, clear module cache, Derived Data and Xcode Caches
#!/bin/bash
#
# curl -O https://gist.githubusercontent.com/ekreutz/b245da335cc10b0d270136b35eb22d1f/raw/43c6d07b0b3d3165af9c10cef18e8709a07ce680/resetXcode.sh && bash ./resetXcode.sh ; rm ./resetXcode.sh
#
if [[ $(whoami) != jenkins ]]; then
echo "Run as jenkins"
exit 1
fi
echo "--- cleaning Xcode ---"
echo "1. Kill Xcode"
killall Xcode
echo "2. Run xcodebuild clean"
xcrun -k
xcodebuild -alltargets clean
echo "3. Clean DARWIN_USER_CACHE_DIR ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
echo "4. Clean DARWIN_USER_CACHE_DIR Xcode stuff"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/com.apple.DeveloperTools/All/Xcode"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)"/com.apple.dt.Xcode*
echo "5. Clean \$HOME Library data"
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
echo "6. Reopen Xcode"
open /Applications/Xcode.app
echo "--- Done cleaning Xcode ---"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment