UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Ultimate Portfolio App - First Steps in UI - Preview Crashs

Forums > Articles

Hi,

I'm in the Ultimate Portfolio App articles "First Steps in UI" part.

My code runs fine in the simulator - so the main part of the code seems to be correct. But my Preview crashes with "Cannot preview in this file - Failed to update preview". The problem appears in the ProjectsView (and as a consequence in the ContentView preview too).

After checking twice the preview code in my projects, I've copied it from the article text into my project code to be sure it is correct without success. The "diagnostics" text behind the preview error is:

RemoteHumanReadableError: Failed to update preview.

The preview process appears to have crashed.

Error encountered when sending 'previewInstances' message to agent.

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

RemoteHumanReadableError: The operation couldn’t be completed. (BSServiceConnectionErrorDomain error 3.)
BSServiceConnectionErrorDomain (3):
==BSErrorCodeDescription: OperationFailed*

My Xcode version is 12.1 on macOS Catalina 10.15.7.

Any ideas, whats the problem?

Best regards

Michael Ehehalt

PS: The course is very nice ... I can't wait for the next episodes 😀

7      

Same error with macOS Big Sur 11.0.1 and Xcode 12.2 👆

5      

What I noticed is that all example variables crash the preview. What it fixed for me is saving the context in the example/preview variable.

static var preview: DataController = {
    let dataController = DataController(inMemory: true)
    let viewContext = dataController.container.viewContext

    do {
        try dataController.createSampleData()
    } catch {
        fatalError("Fatal error creating preview: \(error.localizedDescription)")
    }

    // This line is new.
    dataController.save()

    return dataController
}()

See my question here: https://www.hackingwithswift.com/forums/articles/ultimate-portfolio-app-cleaning-up-core-data-examples/4676

5      

Hacking with Swift is sponsored by RevenueCat

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.