Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Reset Xcode. Clean, clear module cache, Derived Data and Xcode Caches. You can thank me later.
#!/bin/bash
killall Xcode
xcrun -k
xcodebuild -alltargets clean
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang/ModuleCache"
rm -rf "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.$(whoami)/ModuleCache"
rm -rf ~/Library/Developer/Xcode/DerivedData/*
rm -rf ~/Library/Caches/com.apple.dt.Xcode/*
open /Applications/Xcode.app
@lambourn

This comment has been minimized.

Copy link

lambourn commented Feb 15, 2018

later: thanks!

@fadecutmike

This comment has been minimized.

Copy link

fadecutmike commented Mar 8, 2018

you da bomb

@aneeshpanoli

This comment has been minimized.

Copy link

aneeshpanoli commented Mar 24, 2018

Didn't work, still showing me old logs when I relaunch Xcode.

@nabilfreeman

This comment has been minimized.

Copy link

nabilfreeman commented Mar 31, 2018

Boom! Found this via Google. Great job

@neoneye

This comment has been minimized.

Copy link

neoneye commented May 11, 2018

Worked for me. I'm using Swift4.1 (Xcode9.3)

@karianpour

This comment has been minimized.

Copy link

karianpour commented Jun 10, 2018

worked for me XCode9.4. I had XCode10 beta installed, but it did not work. Then I installed XCode 9.4 which was working, then I removed Xcode10beta, after that the Xcode 9.4 did not work until I ran resetXcode.sh

@alanzeino

This comment has been minimized.

Copy link

alanzeino commented Aug 21, 2018

If you're removing DerivedData and the ModuleCache xcodebuild -alltargets clean is probably redundant.

Optionally consider adding pkill -int com.apple.CoreSimulator.CoreSimulatorService, which we do between Xcode upgrades to minimize the potential for simulator flakiness.

@rudifa

This comment has been minimized.

Copy link

rudifa commented Aug 26, 2018

Worked for me with Xcode 9.4.1.
Also, I replaced the last line in script with

TARGET=(*.xcworkspace)
if [ $TARGET == "*.xcworkspace" ]; then
    TARGET=(*.xcodeproj)
    if [ $TARGET == "*.xcodeproj" ]; then
        TARGET=""
    fi
fi
if [ $TARGET != "" ]; then
    open -a "/Applications/Xcode.app" "$TARGET"
else
    echo *** Xcode workspace or project not found
fi
@mikehardy

This comment has been minimized.

Copy link

mikehardy commented Jun 27, 2019

Very nice, fixed an issue I and others had after a react-native-firebase release
invertase/react-native-firebase#2269
thank you!

@stefansidler1993

This comment has been minimized.

Copy link

stefansidler1993 commented Dec 6, 2019

you are a GENIUS !! dammmmm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.