Are there logs that I can access somehow?
The previews were working just fine, but then stopped and I have reverted all changes since and the previews are still broken.
When you get an error in Xcode Previews, an error banner appears in the canvas
Click the "Diagnostics" button in that banner
In the sheet that appears, click "Generate Report" in the bottom left of the sheet
Attach (or make from the folder) the resulting zip file to the bug (will be named something like previews-diagnostics-0123456789.zip)
Has a fix been found for this? Facing the same issue currently.
I am having the same problem with Preview crashing, but not on all files. However, I actually get a crash screen with OK/Reopen. It's a fairly standard Login screen with AppAuth 1.4.0 from package.
Would be thankful for any help as it is painful to run up app in simulator for UI changes.
I had the same problem.
In my case it was the following:
I had an ObservableObject in the App subclass that I was passing through environmentObject() to the content view.
I had forgotten to add a corresponding call to environmentObject() in ContentView_Previews.previews
Once I added that back in it stopped crashing.
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView().environmentObject(Item())
}
}
I hope it helps :-)
I know it's been 3 years, but I found a solution to this issue. If the previews for your project were working just fine, and you started randomly getting preview crashes for certain content views and pages, then it is most likely a programmatic error. Nothing is wrong with your code, but you need to clean and reset the content view code. Then, once the content view preview reloads without crashing, you can paste back the old code and everything should return and work smoothly!
Same thing happened to me. The hint in the error log was about app signing. I had just renamed my app and one of the residuals was that the Xcode set the app to be signed locally instead of "Developer". The app signing was set to "Developer" before the app rename, so I don't know why Xcode set that to a different value. Setting it back to "Developer" fixed the problem for me.
This happened to me too, just changed the preview device "iPhone 15 Pro" to "iPhone 15"
That happen to me because I had a fatalError
somewhere in my view.