firebaseswift4xcode9svprogresshud

Pressing a button more than once in Swift


When I press my button more than once in my app, it gives me an error in my AppDelegate.

Thread 1: signal SIGABRT

Here is my code for my button. If you have any questions, make sure to tell me!

//import Firebase
//import SVProgressHUD
//import UIKit

@IBAction func logInPressed(_ sender: AnyObject) {
    if emailTextField.text != "" || passwordTextField.text != "" {

        FirebaseApp.configure()
        Auth.auth().signIn(withEmail: emailTextField.text!, password: passwordTextField.text!) {
            (user, error) in
            SVProgressHUD.show()
            if error != nil {
                print(error!)
                self.incorrect.isHidden = false
                SVProgressHUD.dismiss()
            } else {
                self.incorrect.isHidden = true
                SVProgressHUD.dismiss()

                self.performSegue(withIdentifier: "Segue9", sender: self)
            }
        }
    } else {
        incorrect.isHidden = false
    }
}

Solution

  • FirebaseApp.configure() needs to be called on the application:didFinishLaunchingWithOptions: function from the AppDelegate

    The crash is possibly occurring because you are calling it twice.