Getting Xcode error "Preparing iPhone Simulator for Previews"

In following a fairly short SwiftUI tutorial, I have gotten the same error in Xcode a couple of times over the last week when just trying to preview. The top bar has a number 2 with a spinning blue animation around it and next to that says "Preparing iPhone Simulator for Previews":

The errors are: Command CompileSwiftSources failed with a nonzero exit code

Swift Compilor Error: Expected identifier in function declaration

Aside from trying to understand what is happening in my instance, a general question is when Xcode has been hung on "Preparing iPhone Simulator for Previews" for at least 20 minutes and the code is very basic, do I just restart Xcode? Should I restart my computer as well? Do a command K clean?

Running: Xcode 13 beta 2 (13A5155e) on MacBook Pro 2019

this is the code (made here as comment not an answer even though the forum format implies the opposite):

import SwiftUI

struct DragGesture04: View {
    
    @State var offset: CGSize = .zero
    
    var body: some View {
        ZStack {
            VStack {
                Text ("\(offset.width)")
                Spacer()
            }
            
            RoundedRectangle(cornerRadius: 20)
                .frame(width: 300, height: 500)
                .offset(offset)
                .scaleEffect(getScaleAmount())
                .gesture(
                    DragGesture()
                        .onChanged { value in
                    withAnimation(.spring()) {
                        offset = value.translation
                    }
                }
                        .onEnded { value in
                    withAnimation(.spring()) {
                        // CGSize(width: 0, height: 0) is the same as .zero (this is gesture stuff)
                        offset = .zero
                    }
                }
                )
        }
    }
    
    func getScaleAmount() -> CGFloat {
        let max = UIScreen.main.bounds.width / 2
        let currentAmount = abs(offset.width)
        let percentage = currentAmount / max
        return 1.0 - min(percentage, 0.5) * 0.5  // that sets smallest floor
        //        return 1.0 - percentage / 2
    }
    
//    func getRotationAmount() -> Double {
//        let max = UIScreen.main.bounds / 2
//        let currentAmount = offset.width
//        let percentage = currentAmount / max
//        let percentageAsDouble = Double(percentage)
//        let maxAngle: Double = 10
//        return percentageAsDouble * maxAngle
//    }
}


struct DragGesture04_Previews: PreviewProvider {
    static var previews: some View {
        DragGesture04()
    }
}

Getting Xcode error "Preparing iPhone Simulator for Previews"
 
 
Q