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:
- Close Xcode.
- Run the following command in the terminal:
xcrun simctl --set previews delete all
- 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
- Delete the CoreSimulator caches directory by running the following command in the terminal:
rm -rf ~/Library/Developer/CoreSimulator/Caches