Failed to build ContentView.swift

Hello! I have problem with ContentView.swift. In Canvas preview I have an error: Failed to build ContentView.swift. Xcode doesn't show an error messages in my code. How to fix this problem? My code in Content View

import SwiftUI

struct ContentView: View {
    @State private var login = ""
    @State private var password = ""
    var body: some View {
        VStack {
            TextField ("Логин", text : $login)
                .textFieldStyle(RoundedBorderTextFieldStyle())
                .padding()
            SecureField("Пароль",text : $password)
                .textFieldStyle(RoundedBorderTextFieldStyle())
                .padding()
            Button(action: loginButtonTapped) {
                            Text("Войти")
                                .foregroundColor(.white)
                                .padding()
                                .frame(maxWidth: .infinity)
                                .background(Color.blue)
                                .cornerRadius(5)
                        }
                        .padding()
                    }
                    .padding()
                }
            
    func loginButtonTapped() {
        // Handle login logic here
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

![]("https://developer.apple.com/forums/content/attachment/927e8aac-a3e0-4dae-8939-6a82cd77a4ff" "title=Снимок экрана 2023-04-28 в 20.55.06.png;width=3024;height=1964")

I run this code without problem, both in Preview (see below) and in simulator, with Xcode 14.2

Which version of Xcode are you using ?

I use Xcode Version 14.3 (14E222b)

  • Remove derived data
  • close from dock simulators and Xcode
  • Open the terminal to run the following command:

xcrun simctl --set previews delete all

Try again and let me know if it works

I have had the same issue with this

Failed to build ContentView.swift
 
 
Q