iOS Development

ios – SwiftUI Preview Replace Failed with Archiving Error

Spread the love


I’m at present studying iOS Widgets, and I’ve encountered this unusual error when I attempt to preview my widget. Here’s what the Diagnostics says:

== PREVIEW UPDATE ERROR:

    PotentialCrashError: Replace failed
    
    ZohoMailWidgetTest might have crashed. Test ~/Library/Logs/DiagnosticReports for any crash logs out of your utility.
    
    ==================================
    
    |  RemoteHumanReadableError
    |  
    |  ArchivingError: failedToEncode(varieties: [SwiftUI.(unknown context at $107d0ac9c).ListRepresentable<SwiftUI.CollectionViewListDataSource<Swift.Never>, SwiftUI.SelectionManagerBox<Swift.Never>>, SwiftUI.(unknown context at $107d0ac9c).ListRepresentable<SwiftUI.CollectionViewListDataSource<Swift.Never>, SwiftUI.SelectionManagerBox<Swift.Never>>])

The related physique of my code appears like this:

struct MailWidgetTestWidgetEntryView : View {
    var entry: Supplier.Entry

    var physique: some View {
        HStack {
            VStack {
                VStack {
                    Picture(systemName: "envelope")
                    Textual content("494")
                }
                
                Picture(systemName: "pencil.circle.fill")
                    .body(maxHeight: .infinity, alignment: .backside)
            }
            
            Record {
                MailWidgetListCellView()
                MailWidgetListCellView()
                MailWidgetListCellView()
            }
        }
    }
}

struct MailWidgetListCellView: View {
    
    var physique: some View {
        HStack {
            VStack {
                HStack {
                    Textual content("Workforce Spark")
                        .font(.subheadline)
                        .body(maxWidth: .infinity, alignment: .main)
                    Textual content("12:15 PM")
                        .font(.caption)
                    
                }
                
                Textual content("Use Spark to reclaim your focus")
                    .font(.subheadline)
                    .body(maxWidth: .infinity, alignment: .main)
            }
            
            Picture(systemName: "checkmark.circle.fill")
                .font(.title)
                .body(maxHeight: .infinity)
        }
    }
}

This error doesn’t pop up once I change my Record right into a VStack as an alternative, like this:

struct MailWidgetTestWidgetEntryView : View {
    var entry: Supplier.Entry

    var physique: some View {
        HStack {
            VStack {
                VStack {
                    Picture(systemName: "envelope")
                    Textual content("494")
                }
                
                Picture(systemName: "pencil.circle.fill")
                    .body(maxHeight: .infinity, alignment: .backside)
            }
            
            VStack { //no errors now
                MailWidgetListCellView()
                MailWidgetListCellView()
                MailWidgetListCellView()
            }
        }
    }
}

I’m unable to search out any resolution to this downside anyplace else. Does anybody understand how I can repair this?

Leave a Reply

Your email address will not be published. Required fields are marked *