Group Group Group Group Group Group Group Group Group

Canvas crashing

Has anyone else noticed that the Canvas / Preview pane crashes when a view contains an @FocusState variable? I also submitted feedback to Apple as I think this is an Xcode bug. But I wondered if anyone else was experiencing a crash in Xcode 13 when you look at the RegisterView in preview?

I’m in that chapter now and it is crashing for me. As you said, it seems to be the @FocusState variable that does it.

Hi,

it looks like an Xcode bug indeed — I have the same crash in 13.2, but it works just fine in 13.1.

I have no idea what the underlying problem is nor why this gets around the problem:

In the <Whatever>_Previews structure, wrap the ContentView() in a ZStack()

        struct ContentView_Previews: PreviewProvider {
            static var previews: some View {
                ZStack {
                     ContentView()
                }
            }
        }