Firebaseui-ios: Type 'ViewController' does not conform to 'FUIAuthDelegate'

Created on 2 Jun 2017  路  19Comments  路  Source: firebase/FirebaseUI-iOS

I was trying to implement Firebase Phone Auth UI into my app. Added following pods to my podfile:
pod 'Firebase'
pod 'Firebase/Auth'
pod 'FirebaseUI/Phone'

Installed pods and added following code to initiate Phone Auth Process:
` let authVC = FUIAuth.defaultAuthUI()
authVC?.delegate = self as! FUIAuthDelegate

    let phone = FUIPhoneAuth(authUI: authVC!)
    authVC?.providers = [phone]
    phone.signIn(withPresenting: self)`

Then implemented FUIAuthDelegate like this:
`extension LoginSignupViewController : FUIAuthDelegate {
/** @fn authUI:didSignInWithUser:error:
@brief Message sent after the sign in process has completed to report the signed in user or
error encountered.
@param authUI The @c FUIAuth instance sending the message.
@param user The signed in user if the sign in attempt was successful.
@param error The error that occurred during sign in, if any.
*/
func authUI(_ authUI: Auth, didSignInWith user: User?, error: Error?) {

}

}`

Now I am getting :

Type 'ViewController' does not conform to 'FUIAuthDelegate' error see attached screen shot for same.

c1183ef6-4793-11e7-8393-96a1b00224bb

question

Most helpful comment

If you have another User class defined within your project, this will cause a namespace conflict. Changing the delegate method to below will fix problem:

func authUI(_ authUI: FUIAuth, didSignInWith user: FirebaseAuth.User?, error: Error?) {
       // ...
}

Another solution would be to typealias FirebaseAuth.User back to FIRUser and use FIRUser in your code instead. i.e. typealias FIRUser = FirebaseAuth.User

All 19 comments

Your code looks fine to me. What pod versions are you using?

My pod version is 1.2.1

What versions of the Firebase libraries are you using?

I am using cocoa pods to install Firebase frameworks in my app like this:
pod 'Firebase'
pod 'Firebase/Auth'
pod 'FirebaseUI/Phone'

Here are my terminal output with version numbers:
Using Firebase (4.0.0)
Using FirebaseAnalytics (4.0.0)
Using FirebaseAuth (4.0.0)
Using FirebaseCore (4.0.0)
Using FirebaseInstanceID (2.0.0)
Using FirebaseUI (4.0.0)

same issue with me

Same Issue here

Using Firebase (4.0.0)
Using FirebaseAnalytics (4.0.0)
Using FirebaseAuth (4.0.0)
Using FirebaseCore (4.0.0)
Using FirebaseDatabase (4.0.0)
Using FirebaseInstanceID (2.0.0)
Using FirebaseStorage (2.0.0)
Installing FirebaseUI 4.0.0 (was 3.1.1)

Currently I fixed it bu removing the delegate and putting a completion handler on present

// Present the default login view controller provided by authUI
authViewController = authUI?.authViewController();
present(authViewController!, animated: true, completion: isLoggedIn)

and setting the delegate to nil
authUI?.delegate = nil

this does mean I can't use a custom AuthUI controllers or check if there are errors on signIn but can't seem to fix it any other way for now

@anilios can you upload a sample that repros this issue? Hard to tell what the cause might be from your screenshot.

@anilios, correct method is:
func authUI(_ authUI: FUIAuth, didSignInWith user: User?, error: Error?) {
FUIAuth not Auth
Please let us know if that helped you.

@yramanchuk But this means we have to downgrade to Firebase 3.0 and I thought the repository was compatible with 4.0. In the sample code it uses Auth instead of FIRAuth

@vatsalyagoel Auth (former FIRAuth) and FUIAuth are different classes.
Library is compatible with 4.0
Here's swift sample.

Looks like this could be a swift compiler issue https://bugs.swift.org/browse/SR-2596. Same error as signatures are expecting -> Void whereas it shows as -> ()

class LoginRegisterViewController: UIViewController, FUIAuthDelegate {
      ^
FirebaseAuthUI.FUIAuthDelegate:12:17: note: protocol requires function 'authUI(_:didSignInWith:error:)' with type '(FUIAuth, User?, Error?) -> Void'; do you want to add a stub?
    public func authUI(_ authUI: FUIAuth, didSignInWith user: User?, error: Error?)
                ^
/Users/vatsalyagoel/Monash/FIT3027/BlogUpiOS/BlogUp/LoginRegisterViewController.swift:29:10: note: candidate has non-matching type '(FUIAuth, User?, Error?) -> ()'
    func authUI(_ authUI: FUIAuth, didSignInWith user: User?, error: Error?) {

I'm also experiencing a similar issue. I'm using the FUIAuthDelegate and it is complaining that I am not conforming to the protocol. However, the required function is present.

screen shot 2017-06-06 at 10 32 02 pm

My versions:
Using Firebase (4.0.1)
Using FirebaseAnalytics (4.0.0)
Using FirebaseAuth (4.0.0)
Using FirebaseCore (4.0.1)
Using FirebaseDatabase (4.0.0)
Using FirebaseInstanceID (2.0.0)
Using FirebaseStorage (2.0.0)
Using FirebaseUI (4.0.0)

@yramanchuk Could you please be more specific with your following reply. I am not able to understand FUIAuth not Auth as I am already using FUIAuth with correct delegate method call as specified by you in your comment:

@anilios, correct method is:
func authUI(_ authUI: FUIAuth, didSignInWith user: User?, error: Error?) {
FUIAuth not Auth
Please let us know if that helped you.

FYI. I have created a new project and I have no errors with FUIAuthDelegate.
However I can't make it working on an existing project ( and I made sure I have the exact same pod versions than with the new one)... Frustrating :(((((

(in both projects I am implementing this required function func authUI(_ authUI: FUIAuth, didSignInWith user: User?, error: Error?){})

If you have another User class defined within your project, this will cause a namespace conflict. Changing the delegate method to below will fix problem:

func authUI(_ authUI: FUIAuth, didSignInWith user: FirebaseAuth.User?, error: Error?) {
       // ...
}

Another solution would be to typealias FirebaseAuth.User back to FIRUser and use FIRUser in your code instead. i.e. typealias FIRUser = FirebaseAuth.User

Can confirm, The project now works with FirebaseAuth.User?

@anilios I thought you were using wrong class: Auth instead of FUIAuth as you mentioned in the initial comment:

func authUI(_ authUI: Auth, didSignInWith user: User?, error: Error?) {

Waiting for the confirmation of the solution proposed by @ocwang

Many thanks @ocwang using your way its working. You are right there is another class named User in my app, which leads to this issue.

func authUI(_ authUI: FUIAuth, didSignInWith user: FirebaseAuth.User?, error: Error?) {
// ...
}

This is working fine now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

netdawgx picture netdawgx  路  7Comments

ghost picture ghost  路  7Comments

alfongj picture alfongj  路  7Comments

georgstrieder picture georgstrieder  路  7Comments

Tayphoon picture Tayphoon  路  6Comments