SwiftUI macOS Preview Crash When Using Custom Row Directly Inside List

I’ve hit a strange SwiftUI preview crash that happens on macOS previews when using a view inside a List’s ForEach, resulting in the error Fatal Error in TableViewListCore_Mac2.swift.

  • Only crashes macOS preview - iPhone/iPad preview doesn't crash.
  • Doesn't crash when actually running the app.

Here’s a minimal reproducible example, causing the preview to crash.

XCode: Version 26.0.1 (17A400)

MacOS: 26.0.1 (25A362)

import SwiftUI

struct Item: Identifiable {
    let id = UUID()
    let name: String
}

struct ItemRow: View {
    let item: Item
    var body: some View {
        HStack {
            Button(action: {}) { Image(systemName: "play") }
            Text(item.name)
            Spacer()
            ProgressView()
        }
    }
}

struct ContentView: View {
    @State private var items = [
        Item(name: "Item A"),
        Item(name: "Item B"),
    ]

    var body: some View {
        List {
            ForEach(items) { item in
                ItemRow(item: item)
            }
        }
    }
}

#Preview("Content view") {
    ContentView()
}

#Preview("Item row") {
    ItemRow(item: Item(name: "Item A"))
}

If I wrap the row in a container, like this:

ForEach(items) { item in
    ZStack {
        ItemRow(item: item)
    }
}

the crash seems to disappear.

  • Has anyone else seen this behavior?
  • What might I be doing wrong?
  • Any ideas about what could be causing this?
Answered by Developer Tools Engineer in 861657022

Hi,

Sorry to hear you are having problems getting previews working. You are hitting a known issue with xcode previews and usage of Lists on macOS.

So far we have no better workaround to offer then what you've identified.

Accepted Answer

Hi,

Sorry to hear you are having problems getting previews working. You are hitting a known issue with xcode previews and usage of Lists on macOS.

So far we have no better workaround to offer then what you've identified.

SwiftUI macOS Preview Crash When Using Custom Row Directly Inside List
 
 
Q