Firebase Check for errors error

I have 4 unexpected errors, all related to the showError variable. I’m a trur beginner and can’'t seem to find what the issue is. Except that all Firebase/Firestore seems to be working well.

-CODE-
import UIKit
import FirebaseAuth
import Firebase

class SignUpViewController: UIViewController {

@IBOutlet weak var usernameTextField: UITextField!


@IBOutlet weak var emailTextField: UITextField!


@IBOutlet weak var passwordTextField: UITextField!


@IBOutlet weak var signUpButton: UIButton!



@IBOutlet weak var errorLabel: UILabel!



override func viewDidLoad() {
    super.viewDidLoad()

}

//Checks the fields and validates that the data is correct. If everything is correct this method returns nil. Otherwise it returns the error message.
func validateFields() -> String? {

    //Check that all fields are filled in. Reacts if ANY field is empty.
    if usernameTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == "" || emailTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == "" || passwordTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == ""
        {
        return "Please fill all fields"
        }

    
    //Check if password is secure

    let cleanedPassword = passwordTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
    
    if Utilities.isPasswordValid(cleanedPassword) == false {
        //password isn't secure
        return "8 characters, 1 special character, 1 number."
    }
    
    return nil
}

//ABOVE WORKING

@IBAction func signUpTapped(_ sender: Any) {
    
        //validate the fields
    let error = validateFields()
    
    if error != nil{
        
        //There's something wrong with the field. Show error message
        showError(error!)
    }
    else {
        
        //Create Cleaned Versions Of The Data
        let username = usernameTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
        let email = emailTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
        let password = passwordTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
        //SPACESAVER for line alignment only
        
        // 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("Error creating User")
            }
            else {
                
                //User Was Created Successfully, Now Save The Username And Password
                let db = Firestore.firestore()
                
                db.collection("users").addDocument(data: ["username":username, "password":password, "uid": result!.user.uid ]) { (error) in
              
                    if error != nil {
                        //Show error message
                        self.showError("user data wasn't saved")
                    }
                }
            
                //Transition to the Home screen
                self.transitionToHome()
        }
        
        
        
    }
}

    
    
func showError(_ message:String) {
    
    errorLabel.text = message
    errorLabel.alpha = 1
}
    
    func transitionToHome(){
        
        let homeViewController =
        storyboard?.instantiateViewController(identifier: Constants.Storyboard.homeViewController) as? HomeViewController
        
        view.window?.rootViewController = homeViewController
        view.window?.makeKeyAndVisible()
    }

}

}

The edited code below might help.

The problem was that you had the two functions showError() and transitionToHome() inside:

@IBAction func signUpTapped(_ sender: Any) {

That will cause the complier to advise "Value of type ‘SignUpViewController’ has no member showError" and also the same error message for transitionToHome

import UIKit
import FirebaseAuth
import Firebase

class SignUpViewController: UIViewController {
    
    @IBOutlet weak var usernameTextField: UITextField!
    @IBOutlet weak var emailTextField: UITextField!
    @IBOutlet weak var passwordTextField: UITextField!
    @IBOutlet weak var signUpButton: UIButton!
    @IBOutlet weak var errorLabel: UILabel!
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    //Checks the fields and validates that the data is correct. If everything is correct this method returns nil. Otherwise it returns the error message.
    func validateFields() -> String? {
        
        //Check that all fields are filled in. Reacts if ANY field is empty.
        if usernameTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == "" || emailTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == "" || passwordTextField.text?.trimmingCharacters(in: .whitespacesAndNewlines) == ""
        {
            return "Please fill all fields"
        }
        
        
        //Check if password is secure
        
        let cleanedPassword = passwordTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
        
        if Utilities.isPasswordValid(cleanedPassword) == false {
            //password isn't secure
            return "8 characters, 1 special character, 1 number."
        }
        
        return nil
    }
    //ABOVE WORKING
    
    @IBAction func signUpTapped(_ sender: Any) {
        
        //validate the fields
        let error = validateFields()
        
        if error != nil{
            
            //There's something wrong with the field. Show error message
            showError(error!)
        }
        else {
            
            //Create Cleaned Versions Of The Data
            let username = usernameTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
            let email = emailTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
            let password = passwordTextField.text!.trimmingCharacters(in: .whitespacesAndNewlines)
            //SPACESAVER for line alignment only
            
            // 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("Error creating User")
                }
                else {
                    
                    //User Was Created Successfully, Now Save The Username And Password
                    let db = Firestore.firestore()
                    
                    db.collection("users").addDocument(data: ["username":username, "password":password, "uid": result!.user.uid ]) { (error) in
                        
                        if error != nil {
                            //Show error message
                            self.showError("user data wasn't saved")
                        }
                    }
                    
                    //Transition to the Home screen
                    self.transitionToHome()
                }                
            }
        }
    }
    
    func showError(_ message:String) {
        
        errorLabel.text = message
        errorLabel.alpha = 1
    }
    
    func transitionToHome(){
        
        let homeViewController =
            storyboard?.instantiateViewController(identifier: Constants.Storyboard.homeViewController) as? HomeViewController
        
        view.window?.rootViewController = homeViewController
        view.window?.makeKeyAndVisible()
    }
}