Skip to content

Instantly share code, notes, and snippets.

@earendildev
Last active June 10, 2022 10:15
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 earendildev/c77791827ab6a3a87bfa3b8d8bb786e2 to your computer and use it in GitHub Desktop.
Save earendildev/c77791827ab6a3a87bfa3b8d8bb786e2 to your computer and use it in GitHub Desktop.
This will delete and purge Xcode from the system and then proceed to reinstall it back (MacOS)
#! /bin/bash
#########################################################
# To Download and Install/Run
# $ sudo -H su -c "$(curl -fsSL https://gist.githubusercontent.com/earendildev/c77791827ab6a3a87bfa3b8d8bb786e2/raw --output $HOME/reinstall-xcode.sh)"
# Created by earendil.dev@gmail.com
#########################################################
# Kill XCode Process
killall Xcode
# Clean Project Folders
xcrun -k
xcodebuild -alltargets clean
# Removing XCode Cache
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
# Purging XCode from System
rm -rf /Applications/Xcode.app
rm -rf ~/Library/Caches/com.apple.dt.Xcode
rm -rf ~/Library/Developer
rm -rf ~/Library/MobileDevice
rm -rf ~/Library/Preferences/com.apple.dt.Xcode.plist
rm -rf ~/Library/Preferences/com.apple.dt.xcodebuild.plist
sudo rm -rf /Library/Developer/CommandLineTools
sudo rm -rf /Library/Preferences/com.apple.dt.Xcode.plist
sudo rm -rf /System/Library/Receipts/com.apple.pkg.XcodeExtensionSupport.bom
sudo rm -rf /System/Library/Receipts/com.apple.pkg.XcodeExtensionSupport.plist
sudo rm -rf /System/Library/Receipts/com.apple.pkg.XcodeSystemResources.bom
sudo rm -rf /System/Library/Receipts/com.apple.pkg.XcodeSystemResources.plist
sudo rm -rf /private/var/db/receipts/com.apple.pkg.Xcode.bom
# Installing XCode
printf "Lets Install XCode"
sudo xcode-select --install
sudo xcode-select --reset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment