X

Xcode 清掉 Cache 的方法 - 2019

Xcode 編譯時,都會產生不少 Cache 的檔案,要怎麼清除掉這些檔案呢?

  • 註:目前環境 Xcode 10,目前看到 Xcode 10 以前都沒問題,10 以後還不確定

Xcode 清掉 Cache 的方法

想要清掉 Xcode 產生的 Cache,除了要省空間外,主要是遇到某些情況,想要將環境清乾淨,整個重新編譯,確認問題用。

Xcode 清除 Cache 的步驟

  1. 開啟 Xcode
    1. Command + Shift + K
    2. Command + Option + Shift + K
  2. 開啟 Terminal
    1. ls ~/Library/Developer/Xcode/DerivedData/ModuleCache # 先看看
    2. rm -fr ~/Library/Developer/Xcode/DerivedData/ModuleCache # 擔心的話建議先 mv 到自己目錄
    3. ls -lh "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.jon/ModuleCache" # path: /var/folders/gq/xxxxxxxxxxxxxxx/C/org.llvm.clang.jon/ModuleCache
    4. rm -fr "$(getconf DARWIN_USER_CACHE_DIR)/org.llvm.clang.jon/ModuleCache" # 擔心的話建議先 mv 到自己目錄
    5. defaults delete com.apple.dt.Xcode # 清掉 xcode build cache

相關網頁

  • 下述摘錄自此篇:Xcode Quick Fix - Clear Cache 此篇作者有直接寫一隻程式:fix-xcode.rb
    1. Clean the Build
      • Command + Shift + K
      • Product → Clean Build Folder
    2. Clean the Build Folder
      • Command + Option + Shift + K
    3. Reset the Simulator Content and Settings
      • Menu Bar → iOS Simulator → Reset Contents And Settings
    4. Delete Derived Data
      • Menu Bar → Window → Organizer → Projects → Select Your Project
    5. Delete the Module Cache
      • rm -fr ~/Library/Developer/Xcode/DerivedData/ModuleCache
    6. Delete Xcode Preferences
      • defaults delete com.apple.dt.Xcode # terminal 直接輸入即可
  • 下述摘錄自此篇:How to clear Xcode cache and stop crashes
    1. clean build: Command + Shift + K
    2. Clean out the build folder: Command + Shift + Option + K
    3. Reset Simulator content and settings: menu → iOS Simulator → click Reset Content and Settings
    4. Delete derived data: rm -fr ~/Library/Developer/Xcode/DerivedData/ModuleCache
    5. Launch Terminal: defaults delete com.apple.dt.Xcode
  • How to Empty Caches and Clean All Targets Xcode 4 and later
  • 乾淨的移除 Xcode - Qiita
Tsung: 對新奇的事物都很有興趣, 喜歡簡單的東西, 過簡單的生活.
Related Post