1

I'm setting up Firebase with Email authentication, I copying a source code from a website, on which they use the following code, but they do not mention anything about this error.

I have tried every question on SO and GitHub but none of them seem to work.

var body: some View {
    VStack {
        TextField($email, placeholder: Text("email address"))
        SecureField($password, placeholder: Text("Password"))
        if (error) {
            Text("An error")
        }
        Button(action: signIn) {
            Text("Signing in")

        }
    }
}

That line in the middle of the if statement is giving me the following error:

Text("An error")

Type of expression is ambiguous without more context
2
  • And where does error come from? Oct 17, 2019 at 20:48
  • 1
    I meant the variable and why can’t you sanitize your error messages before posting them here? Oct 17, 2019 at 20:50

1 Answer 1

1

Seems like this is an old SwiftUI code. Placeholder argument of the TextField changed a bit since then.

change it to:

var body: some View {
    VStack {
        TextField("email address", text: $email)
        SecureField("Password", text: $password)
        if (error) {
            Text("Oh an error!")
        }
        Button(action: signIn) {
            Text("Signing in")
        }
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.