无法使用Firebase身份验证:FIRAuth.auth无效

And*_*Qin 0 xcode ios firebase swift

我已经在这个问题上苦苦挣扎了几天,我是一个新手,我无法找到解决方案.我正在尝试使用XCode 8.3.3创建用户注册和登录页面,并使用Firebase作为数据库.

我的代码如下:

import UIKit
import Firebase
import FirebaseAuth

class SignUpViewController: UIViewController {

    //Outlets
    @IBOutlet weak var emailTextField: UITextField!
    @IBOutlet weak var passwordTextField: UITextField!

    //Sign Up Action for email
    @IBAction func createAccountAction(_ sender: AnyObject) {

        if emailTextField.text == "" {
            let alertController = UIAlertController(title: "Error", message: "Please enter your email and password", preferredStyle: .alert)

            let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
            alertController.addAction(defaultAction)

            present(alertController, animated: true, completion: nil)   
        } else {
            FIRAuth.auth().createUser(withEmail: emailTextField.text!, password: passwordTextField.text!) { (user, error) in

            if error == nil {
                print("You have successfully signed up")
                //Goes to the Setup page which lets the user take a photo for their profile picture and also chose a username

                let vc = self.storyboard?.instantiateViewController(withIdentifier: "Home")
                self.present(vc!, animated: true, completion: nil)

            } else {
                let alertController = UIAlertController(title: "Error", message: error?.localizedDescription, preferredStyle: .alert)

                let defaultAction = UIAlertAction(title: "OK", style: .cancel, handler: nil)
                alertController.addAction(defaultAction)

                self.present(alertController, animated: true, completion: nil) 
            }
        }
    }   
}
Run Code Online (Sandbox Code Playgroud)

有问题的部分是FIRAuth.auth.错误说" FIRAuth已经重命名为Auth",如果我应用了这样的修复,虽然内置成功,但我只能看到白屏.如果我删除了代码,那么我可以看到之前创建的正常登录画面.

另一件事是当我输入导入FirebaseAuth出现在建议的单词列表中的红线时FirebaseAuth,我仍然继续.

请帮忙.我不知道为什么会这样.可能有任何丢失的pod文件?非常感激.

故事板: 故事板

Vla*_*hev 7

FIRAuth成为Auth最后一个Firebase版本.链接到文档

import Firebase
Run Code Online (Sandbox Code Playgroud)

然后,在该application:didFinishLaunchingWithOptions:方法中,初始化FirebaseApp对象:

// Use Firebase library to configure APIs
FirebaseApp.configure()
Run Code Online (Sandbox Code Playgroud)

现在你可以在你的文件中使用(也import Firebase)

Auth.auth().createUser(withEmail: email, password: password) { (user, error) in
    // ...
}
Run Code Online (Sandbox Code Playgroud)

希望能帮助到你