senty senty - 2 years ago 371
Swift Question

Firebase Upgrading From 2.5.1 to 3.2.1

I tried upgrading Firebase to

however I faced with bunch of errors.

1- First error I face is, before, I was using
(authData: FAuthData)
but after the upgrade I started receiving error:

Use of undeclared type

2- For the references, I was using..

let rootRef = Firebase(url:dataURL)

Now I tried changing it to

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

Value of type
has no member

3- Similarly, if I use

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

4- Lastly, it doesn't let me place
in AppDelegate even though I used
import Firebase
. It doesn't seem like it knows about
in AppDelegate

What is the way of upgrading Firebase from 2.5.1 to 3.2.1? Is there a guide for upgrading it? What am I missing/doing wrong?

Answer Source

This question has already been answered here-

Why my Firebase pod 3.x won't get installed properly?

Here are the highlights-

pod update

You need to run pod update once before installing the Firebase pod and it will install the correct version when you do it next time.

Please check the original answer for further explanation.


FIRAuth might be what you are looking for in 3.x From the Docs- 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)


For Sign out (unauth in your case)-

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

This should definitely work. Of course, you need to add GoogleService-Info.plist to your project from firebase console as mentioned in the comments.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download