How to clear/reset SwiftUI Preview Caches?

If you run into any SwiftUI Preview related issue, then there are high chance that you are facing that issue due to some cached preview data. Here are the steps to reset the SwiftUI Preview Caches:

  1. Close Xcode.
  2. Run the following command in the terminal:
    xcrun simctl --set previews delete all
    
  3. Cross-check if all the data is deleted from ~/Library/Developer/Xcode/UserData/Previews directory. If not then you can delete this directory manually by running the following command in the terminal:
    rm -rf ~/Library/Developer/Xcode/UserData/Previews
    
  4. Delete the CoreSimulator caches directory by running the following command in the terminal:
    rm -rf ~/Library/Developer/CoreSimulator/Caches
    

You've successfully subscribed to Developer Insider
Great! Next, complete checkout for full access to Developer Insider
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.