Last active
May 20, 2025 12:47
-
-
Save MiklinMA/f2848e7f871ecdf876b43a32fc2dcce6 to your computer and use it in GitHub Desktop.
Xcode reset. An easy way to clear DerivedData, Xcode caches and module cache.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Xcode" | |
activate | |
set targetProject to active workspace document | |
repeat 60 times | |
if loaded of targetProject is true then | |
exit repeat | |
end if | |
delay 0.5 | |
end repeat | |
set action to clean targetProject | |
repeat 60 times | |
if completed of action is true then | |
exit repeat | |
end if | |
delay 0.5 | |
end repeat | |
quit | |
end tell | |
set cacheDir to do shell script "getconf DARWIN_USER_CACHE_DIR" | |
set whoAmI to do shell script "whoami" | |
tell application "Finder" | |
try | |
delete folder (cacheDir & "clang/ModuleCache") | |
end try | |
try | |
delete folder (cacheDir & "clang." & whoAmI & "/ModuleCache") | |
end try | |
try | |
delete every item of folder (cacheDir & "org.llvm.clang/ModuleCache") | |
end try | |
try | |
delete every item of folder (cacheDir & "org.llvm.clang." & whoAmI & "/ModuleCache") | |
end try | |
try | |
delete every item of folder ((path to home folder as text) & "Library:Developer:Xcode:DerivedData") | |
end try | |
try | |
delete every item of folder ((path to home folder as text) & "Library:Caches:com.apple.dt.Xcode") | |
end try | |
end tell | |
tell application "Xcode" to activate |
Author
MiklinMA
commented
Mar 6, 2024
- create an Apple script
- export the script as an application
- just use spotlight (⌘+Space) and type "Xcode reset" in any case of unusual Xcode behaviour.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment