Learn Courses My Dashboard

Error Message on Firebase Auth + Custom iOS Login Page

Hello Friends!

So I am getting back into things after 2 years, and it seems xCode may have gone through an update? Any ways, I am following along the steps via the Firebase Auth YouTube video from July 24, 2019. My login was working and capturing in Firebase, now it is not. Also - when I do hit sign up, it does not take me to the ‘Welcome’ screen. Here are my errors i am receiving. I can for the life of me figure out the fix!

Thank you!

Welcome to the community!

Can you show me the screenshot for transitionToHome?

It seems like you’re missing a piece here and there rather than this being an Xcode update

But yes either way Xcode updates every year with changes and that can make it difficult to follow older tutorials sometimes (depending on the update)

1 Like

Thank you! Here is the screenshot of

here is my constant view as wellScreen Shot 2022-02-16 at 3.41.52 PM

Can you paste the whole VC? I’m thinking the function might be on the wrong place

Paste your code in as text, rather than providing a screenshot.

To format the code nicely, place 3 back-ticks ``` on the line above your code and 3 back-ticks ``` on the line below your code. The 3 back-ticks must be the ONLY characters on the line. The back-tick character is located on the same keyboard key as the tilde character ~ (which is located below the Esc key). You can also highlight an entire code block and click the </> button on the toolbar to wrap the block for you.

This also makes it easier for anyone assisting as they can copy the code and carry out some testing.

Ah yeap, sorry! Probably easier if i started that way too. Thank you!
// SignUpViewController.swift
// LogInTesting_HBK
// Created by Neal Revane on 2/8/22.

import UIKit
import FirebaseAuth
import Firebase
import FirebaseFirestore

class SignUpViewController: UIViewController {
    @IBOutlet weak var firstNameTextField: UITextField!
    @IBOutlet weak var lastNameTextField: UITextField!
    @IBOutlet weak var emailTextField: UITextField!
    @IBOutlet weak var passwordTextField: UITextField!
    @IBOutlet weak var signUpButton: UIButton!
    @IBOutlet weak var errorLabel: UILabel!
    override func viewDidLoad() {

        // Do any additional setup after loading the view.
    func setUpElements() {
        //Hide the error label
        errorLabel.alpha = 0
        //Style the elements
    // Check the fields and validate that the data is correct. If everything is correct, this method returns nil. Otherwise, t returns the error message

    func validateFields() -> String? {

        //Check that all fields are filled in
        if firstNameTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == "" ||
            lastNameTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == "" ||
            emailTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == "" ||
            passwordTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == "" {
            return "Please fill in all required fields."
        //Check if the password is secure
        let cleanedPassword = passwordTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
        if Utilities.isPasswordValid(cleanedPassword) == false {
            //Password isnt secure enough
            return "Please make sure your password is at least 8 characters, contains a capitalized letter and special character"
        return nil
        func signUpTapped(_ sender: Any){
        // validate the fields
        let error = validateFields()
            if error != nil {
                //There something wrong with the field show error message
                showError(message: error!)
            else {
         // Create clean versions of the data
                let firstname = firstNameTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
               let lastname = lastNameTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
               let email = emailTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
                let password = passwordTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
                //create the user
                Auth.auth().createUser(withEmail: email, password: password) { (result, err) in
                //Check for errors
                    if err != nil {
                 // There was an error creating the user
                        self.showError(message: "Error Creating the User")
                    else {
                        // User was created successfully, now store the first name and last name
                        let db = Firestore.firestore()
                        db.collection("users").addDocument(data: ["firstname":firstname, "lastname":lastname, "uid": result!.user.uid]) { (error) in
                            if error != nil {
                        //transition to the home screen
    func showError ( message:String) {
        errorLabel.text = message
        errorLabel.alpha = 1
    func transitionToHome() {
        let homeViewController = storyboard?.instantiateViewController(withIdentifier: Constants.Storyboard.homeViewController) as? HomeViewController
        view.window?.rootViewController = homeViewController