如何修复错误FIRAuth已更改为Auth然后当我将其更改为Auth时它表示它是一个未解析的标识符?我需要做什么?

时间:2018-02-17 21:09:11

标签: swift firebase

我如何修复FIRAuth错误,然后修复出现在单词后的Auth错误?

下面的代码是我开发的代码。 FIRAuth错误是:

  

FIRAuth已更改为Auth。

然后,Auth错误是一个未解析的标识符。

import UIKit
import Firebase

class ViewController: UIViewController {
    @IBOutlet weak var emailField: UITextField!
    @IBOutlet weak var passwordField: UITextField!

    var userUid: String!

    func goToCreateUserVC(){
        performSegue(withIdentifier: "SignUp", sender: nil)
    }

    override func prepare(for segue: UIStoryboardSegue, sender: Any?){
        if segue.identifier == "SignUp" {
            if let destination = segue.destination as? UserVC {
                if userUid != nil {
                    destination.userUid = userUid
                }
                if emailField.text != nil {
                    destination.emailField = emailField.text
                }
                if passwordField.text != nil {
                    destination.passwordField = passwordField.text
                }
            }
        }
    }

    @IBAction func signInTapped(sender: Any){
        if let email = emailField.text, let password = passwordField.text {
           FIRAuth.auth().signIn(withEmail: email, password: password, completion: { (user,error) in
                if error == nil{
                    if let user = user {
                        self.userUid = user.uid
                        self.goToCreateUserVC()
                    }
                }else{
                    self.goToCreateUserVC()
                }
            });
        }
    }
}

1 个答案:

答案 0 :(得分:1)

首先,更新您的方法:Auth.auth()。signIn

然后,从documentation: 在Podfile中安装依赖项:

pod 'Firebase/Auth'

在方法应用程序中初始化Firebase对象:didFinishLaunchingWithOptions:

FirebaseApp.configure()