WWDC22 SALE: Save 50% on all my Swift books and bundles! >>

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 😀

3      

Same error with macOS Big Sur 11.0.1 and Xcode 12.2 👆

1      

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

1      

Hacking with Swift is sponsored by Emerge

SPONSORED Optimize your app’s startup time, binary size, and overall performance using Emerge’s advanced app optimization and monitoring tools. Reliably measure app size, speed up your app's startup time with Emerge's Launch Booster, and much more. Emerge is actively used by many of the top mobile development teams in the world.

Find out 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.