Skip to content

Instantly share code, notes, and snippets.

@MiklinMA
Last active March 7, 2024 07:36
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 MiklinMA/f2848e7f871ecdf876b43a32fc2dcce6 to your computer and use it in GitHub Desktop.
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.
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
@MiklinMA
Copy link
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