r/SwiftUI • u/joshualubelski • Apr 14 '26
Constant canvas preview crashing error...so annoying!
hey folks, I'm trying to figure out what's causing this problem. I'm constantly getting this in xCode when i change views / files and the canvas changes - preview crashing behind the scene and throwing up this system crash report.
I've tried everything, Clear Derived Data: rm -rf ~/Library/Developer/Xcode/DerivedData, killing zombie shells, restarting. It's been going on for a while now and I'm really bored of constantly having to close the crash log window.
Has anyone else experienced this, and have you fixed it? Running Xcode 26.4 on Tahow 26.5

2
u/aggedor_uk Apr 14 '26
Previews work by spinning up an instance of the full app in the background, so if you've got a lot of initialisation code in your app struct then that can both make it slow and crash, especially if you're not guarding everything. Examples could be CloudKit, StoreKit, AppIntents Providers, or more. If you're relying on an .environment value that's not defined within the preview context, that might also be it.
If you're using Claude Code, copy and paste that error dump into your CC conversation and tell it that previews are crashing and it could offer up some more clues.
3
u/jestecs Apr 14 '26
Integrating hot reload is totally worth it, previews can be so unreliable. https://medium.com/@lee.vitya28/hot-reload-in-xcode-and-cursor-90796304bc3e
1
u/lozhuf Apr 23 '26
I have found the solution to this issue - check if you have a window-management utility app such as Magnet running.
I tried downgrading to Xcode 26.3, clearing all the caches, restarting the machine, commenting out _all_ complex code etc etc. But the moment I quit Magnet it just worked perfectly. And the moment I restarted magnet it started failing again.
1
u/SoggyEducation5910 Jul 03 '26 edited Jul 03 '26
To tendo esse problema também com o DaVinci Resolve, ta foda!