TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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      

@TD540  

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 Superwall.

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

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.