Xcode 13.2 - Preview stops working with SwiftUI List

I have a list of rows of articles in a SwiftUI List. The code is the following:

struct ArticleListView: View {
    var articles: [Article]
    var body: some View {
        List {
            ForEach(articles) { a in
                ArticleRow(article: a)
            }
        }
    }
}

When I run it in the simulator it works like a charm but the Preview Canvas always returns with an error. The Article struct conforms to Identifiable so this is not really the problem.

I have tried to play a little with the view. When I replaced the ForEach with the following:

        List {
            ForEach(1..<5) { i in
                ArticleRow(article: articles[i])
            }
        }

the preview displayed the list beautifully.

But when I replaced the ForEach with the indices, like this:

        List {
            ForEach(articles.indices, id:\.self) { i in
                ArticleRow(article: articles[i])
            }
        }

the Preview canvas was not able to display the view.

The error message is the same for all scenarios:

MessageSendFailure: Message send failure for update

==================================

|  MessageError: Connection interrupted

Does anybody have any idea how to solve this, or is this maybe a bug in the current (13.2 and 13.2.1) Xcode version?

Thank you.

Answered by ForumsContributor in

I think you will need to share the code to ArticleRow, for anyone to be able to help you with this.

Can you please share your Article Struct?

Xcode 13.2 - Preview stops working with SwiftUI List
 
 
Q