NEW: Learn to build the incredible iOS 15 Weather app today! >>

Ultimate Portfolio App - First Steps in UI - Preview Crashs

Forums > Articles


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 😀



Same error with macOS Big Sur 11.0.1 and Xcode 12.2 👆


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.

    return dataController

See my question here:


Hacking with Swift is sponsored by Sentry

SPONSORED With Sentry’s error and performance monitoring for iOS, you see mobile vitals that actually matter, can solve any latency issues quickly, and learn how each release is performing over time.

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.