Xcode 13.2.1 swiftUI Previews crash

update Xcode13.2.1 from App Store, the swiftUI previews function crashed, it alerts: "file '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/usr/lib/swift/shims/System.h' has been modified since the module file '/var/folders/hd/64g86r110qq26_sj_p88w9x81mrjx0/C/clang/ModuleCache/12TRQXIDQ8QQD/SwiftShims-2TTN5UXQBRCCQ.pcm' was built: mtime changed"

  • I am having this same issue with all of my swiftui projects, including newly created ones

Add a Comment

Accepted Reply

Meet the same problem in Xcode 13.2

I just used rm -rf /path/to/C/clang/ModuleCache command to delete ModuleCache and it works now

  • Works perfectly. For anyone else, it's not the ModuleCache inside DerivedData. You have to go to /var/folders/h2 (in my case) and you have a large name in folder. Inside this folder you have to write rm -rf C/clang/ModuleCache.

    The error in Xcode tells you the exact folder.

    Thanks @bestswifter.

  • Thanks! I can work again))) I would not stand another reinstallation of xcode

Add a Comment

Replies

Meet the same problem in Xcode 13.2

I just used rm -rf /path/to/C/clang/ModuleCache command to delete ModuleCache and it works now

  • Works perfectly. For anyone else, it's not the ModuleCache inside DerivedData. You have to go to /var/folders/h2 (in my case) and you have a large name in folder. Inside this folder you have to write rm -rf C/clang/ModuleCache.

    The error in Xcode tells you the exact folder.

    Thanks @bestswifter.

  • Thanks! I can work again))) I would not stand another reinstallation of xcode

Add a Comment

same problem, i tried Cleaning Xcode Derived Data but nothing changed i was able to fix it by going into /var/folders/8x/y1lvpw3s0b33_tbjshybhm280000gn/C/clang and deleting the ModuleCache as proposed by bestswifter

Deleting the ModuleCache worked! A more generic (and safer) way to find and delete it would be:

rm -rf "$(getconf DARWIN_USER_CACHE_DIR)clang/ModuleCache"

  • Thank you! This worked for me! Had the same problem with previews not working in all my projects. Not anymore!

Add a Comment