SwiftUI " Type '()' cannot conform to 'View' " error and Preview not working

Hi all,

I have the above error message in the following code:

import SwiftUI

struct ContentView: View {
    let mainColor = Color(red: 20/255, green: 28/255, blue: 58/255)
    let accentColor = Color(red: 48/255, green: 105/255, blue: 240/255)
    var body: some View {
        ZStack {
            mainColor.ignoresSafeArea()
            VStack{
                Text("1/10")
                    .font(.callout)
                    .multilineTextAlignment(.center)
                    .padding()
                Text("what was the first computer bug?")
                    .font(.largeTitle)
                    .bold()
                    .multilineTextAlignment(.center)
                Spacer()
                HStack {
                    Button(action: {
                        print("Tapped on Choice 1")
                    }, label: {
                        Text("Ant")
                            .font(.body)
                            .bold()
                            .multilineTextAlignment(.center)
                            .padding()
                            .border(accentColor, width: 4)
                    })
                    Button(action: {
                        print("Tapped on Choice 2")
                    }, label: {
                        Text("Beetle")
                            .font(.body)
                            .bold()
                            .multilineTextAlignment(.center)
                            .padding()
                            .border(accentColor, width: 4)
                    })
                    Button(action: {
                        print("Tapped on Choice 3")
                    }, label: {
                        Text("Moth")
                            .font(.body)
                            .bold()
                            .multilineTextAlignment(.center)
                            .padding()
                            .border(accentColor, width: 4)
                    })
                    Button(action: {
                        print("Tapped on Choice 4")
                    }, label: {
                        Text("Fly")
                            .font(.body)
                            .bold()
                            .multilineTextAlignment(.center)
                            .padding()
                            .border(accentColor, width: 4)
                    })
                }
            }
        }

#Preview {
            ContentView()
        }
    }
}
    
    


The error message comes up in the Preview line near the bottom, above ContentView()

Also Preview is not showing in the editor so unable to see the iPhone screen. The simulator was working but now the build fails.

I have tried the following:

  1. Created a new project and followed instructions from Build iOS Apps with SwiftUI again
  2. Googled the problem and not found any applicable solutions
  3. Uninstalled and reinstalled Xcode
  4. Stood up, spun round 3 times and sat down again :upside_down_face:

Any help, expertise, knowledge would be appreciated! :slight_smile:

Solved, missing an extra }