Skip to content

Instantly share code, notes, and snippets.

@MiklinMA
Last active August 15, 2025 07:01
Show Gist options
  • Select an option

  • Save MiklinMA/f2848e7f871ecdf876b43a32fc2dcce6 to your computer and use it in GitHub Desktop.

Select an option

Save MiklinMA/f2848e7f871ecdf876b43a32fc2dcce6 to your computer and use it in GitHub Desktop.

Revisions

  1. MiklinMA revised this gist Mar 7, 2024. No changes.
  2. MiklinMA renamed this gist Mar 6, 2024. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. MiklinMA created this gist Mar 6, 2024.
    45 changes: 45 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,45 @@
    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