Cannot preview in this file — Landmarks.app may have crashed

Hello,


Stuck on the Badge section of SwiftUI Tutorials. Issue started on Macbook Pro, and I've tested on my iMac as well with the same results. Test on both the completed and the starting point Xcode projects. When trying to preview the Badge views, I receive the error in preview "Cannot preview in this file — Landmarks.app may have crashed"


The build succeeds, but I cannot preview.



Diagnostic report:


Landmarks.app crashed: Error Domain=render service Code=12 "Rendering service was interrupted" UserInfo={NSLocalizedDescription=Rendering service was interrupted}


Any help would be greatly appreciated! I am a struggling ameteur developer.


Sincerely,

Chris

Replies

Interesting update and discovery. Removing

.fill(Color.black)

Resolves the issue initially. From completed badge section, removing all the .fill from Badge files fixes issue. I haven't completed the project yet, and I still don't quite understand this. Any knowledge would be still greatly appreciated!



//Badge.swift
import SwiftUI

        struct Badge: View {
            var body: some View {
                Path { path in
                    var width: CGFloat = 100.0
                    let height = width
                    path.move(to: CGPoint(x: width * 0.95, y: height * 0.20))
                   
                    HexagonParameters.points.forEach {
                        path.addLine(
                            to: .init(
                                x: width * $0.useWidth.0 * $0.xFactors.0,
                                y: height * $0.useHeight.0 * $0.yFactors.0
                            )
                        )
                    }
                }
                .fill(Color.black)
            }
        }

        #if DEBUG
        struct Badge_Previews: PreviewProvider {
            static var previews: some View {
                Badge()
            }
        }
        #endif

Seems to be a known bug, noted in XCode beta5 release notes.


SwiftUI Tutorials Known Issues

Using the Path structure may cause your app to crash if youʼre using the SDKs included in Xcode 11 beta 5. As a result, you may be unable to successfully follow the steps in the Drawing Paths and Shapes tutorial. (53523206)


Only good solution is to wait for beta 6