Firebase 从 2.5.1 升级到 3.2.1

Firebase Upgrading From 2.5.1 to 3.2.1

我尝试将 Firebase 升级到 3.2.1,但是我遇到了一堆错误。

1- 我遇到的第一个错误是,之前我使用的是 (authData: FAuthData) 但升级后我开始收到错误消息:

Use of undeclared type FAuthData


2- 对于参考资料,我使用的是..

let rootRef = Firebase(url:dataURL)
rootRef.unauth()

现在我尝试将其更改为

let rootRef = FIRApp(named: dataURL)   // it forces me change into that,
rootRef.unauth()                       // and this line throws an error.

Value of type FIRApp? has no member unauth

3- 同样,如果我使用

let loginRef = FIRApp(named: dataURL)
loginRef.authUser(     // has no member `authUser`

4- 最后,它不允许我在 AppDelegate 中放置 FIRApp.configure(),即使我使用了 import Firebase。它似乎不知道 AppDelegate

中的 FIRApp

Firebase从2.5.1升级到3.2.1的方法是什么?有升级指南吗?我 missing/doing 哪里错了?

这里已经回答了这个问题-

这里是亮点-

pod update

在安装 Firebase pod 之前,您需要 运行 pod update 一次,下次安装时它会安装正确的版本。

请查看原始答案以获得进一步解释。

更新

FIRAuth 可能是您在 3.x

中寻找的内容

来自文档-

Update your Authentication Code

FIRAuth.auth()!.signInAnonymouslyWithCompletion() { (user, error) in
if let error = error {
    print("Sign in failed:", error.localizedDescription)
} else {
    print ("Signed in with uid:", user!.uid)
}

}

对于注销(unauth 在你的情况下)-

try! FIRAuth.auth()!.signOut()

这绝对有效。当然,如评论中所述,您需要从 firebase 控制台将 GoogleService-Info.plist 添加到您的项目中。