senty senty - 5 months ago 183
Swift Question

Firebase Upgrading From 2.5.1 to 3.2.1

I tried upgrading Firebase to

3.2.1
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
FAuthData






2- For the references, I was using..

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


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
FIRApp?
has no member
unauth



3- Similarly, if I use

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





4- Lastly, it doesn't let me place
FIRApp.configure()
in AppDelegate even though I used
import Firebase
. It doesn't seem like it knows about
FIRApp
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

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.

UPDATE

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.