Preview keeps crashing

My Xcode preview keeps crashing and doesn't preview my project. But I have another project that previews perfectly fine. So if anybody knows how to fix this I would gladly appreciate it

Replies

Sorry to hear you are having problems getting previews working. Crash logs for the preview app will show up in ~/Library/Logs/DiagnosticReports/. It can sometimes take a few minutes for it to generate, so give it a bit time and then see if any are there. Hopefully that will give you some helpful hints on what is causing the crash.
Based upon your description of the situation I am guessing that the preview version of the app has some stale app data (perhaps an old version of a CoreData container that doesn’t have migration support to the current version?). To start from a fresh slate you can use the terminal app and run xcrun simctl —set previews delete all.

If that still doesn’t resolve issue then probably best next step will be to file a feedback with diagnostics.
We will need the diagnostics Xcode Previews generates in order to make sure we understand the error the previews system is encountering.
  1. When you get an error in Xcode Previews, an error banner appears in the canvas

  2. Click the “Diagnostics” button in that banner

  3. In the sheet that appears, click “Generate Report” in the bottom left of the sheet

  4. Attach (or make from the folder) the resulting zip file to the bug (will be named something like previews-diagnostics-0123456789.zip)

Thanks, that terminal app command suggestion was helpful in fixing a preview crash problem that I had.

There were two additional things that I had to do:

1 - if the simctl utility is not on your path (likely the default case), then point your terminal at: Applications/Xcode/Contents/Developer/usr/bin (you may need to unhide hidden folders and/or open the Xcode package), and do the command as: xcrcun ./simctl --set previews delete all

2 - the -set option actually requires a double dash: --set