1

I'm in the process of integrating the Firebase Auth UI to my app, and for some reason I keep getting this error:

Type 'LoginViewController' does not conform to protocol 'FUIAuthDelegate'

Before you start downvoting me into oblivion, I promise that I'm not an idiot. The FUIAuthDelegate only has one required function, which is listed farther down in the issue inspector:

Protocol requires function 'authUI(_:didSignInWith:error:)' with type '(FUIAuth, User?, Error?) -> Void'; do you want to add a stub?

And then this:

Candidate has non-matching type '(FUIAuth, User?, Error?) -> ()'

The thing is, I've got that function in my class, and I'm fairly certain that I'm conforming to the protocol... here's my ViewController's code:

import UIKit
import FirebaseAuth
import FirebaseAuthUI


typealias FIRUser = FirebaseAuth.User

class LoginViewController: UIViewController {

    @IBOutlet weak var loginButton: UIButton!

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    @IBAction func loginButtonTapped(_ sender: Any) {
        print("Login Button Tapped")

        guard let authUI = FUIAuth.defaultAuthUI()
            else { return }

        authUI.delegate = self

        let authViewController = authUI.authViewController()
        present(authViewController, animated: true)    
    }
}
extension LoginViewController: FUIAuthDelegate {
    func authUI(_ authUI: FUIAuth, didSignInWith user: User?, error: Error?) {
        print("")
    }
}

Am I insane? Can someone tell me what I'm missing here?

AL.
  • 36,815
  • 10
  • 142
  • 281
Luke Solomon
  • 144
  • 6

2 Answers2

4

Remove the FUIAuthDelegate protocol from the LoginViewController extension:

extension LoginViewController {
func authUI(_ authUI: FUIAuth, didSignInWith user: User?, error: Error?) {
    print("")
}

}

I just confirmed that when I added FUIAuthProtocol to my own app, I got the same error you saw. Without it, it runs fine.

Jen Person
  • 7,356
  • 22
  • 30
  • Any idea why this might be happening? I have a friend who is using the Firebase sdk and isn't having this issue. – Luke Solomon Jun 21 '17 at 22:08
  • Honestly I don't know; wish I could tell you more about it! Your friend is using FUIAuth on iOS as well? Are you both using the same version of the SDK? – Jen Person Jun 21 '17 at 22:13
  • We're looking at it now, and it looks like he was using version 4.0 of FirebaseUI, and I'm using the most recent version. He just ran a pod update to get himself up to the most recent version, and it's still working for him. I'm glad you saw the same error because I've felt like a crazy person these past few days. – Luke Solomon Jun 22 '17 at 00:12
  • I know what you mean! I wish I had an explanation for you. I'll ask the developer if he has any insight. – Jen Person Jun 22 '17 at 00:41
  • 1
    I looked into it and apparently there is a namespace conflict. Instead of using 'didSignInWith user: User?' the function should be changed to 'didSignInWith user: FirebaseAuth.User?' – Luke Solomon Jun 22 '17 at 17:49
  • Thanks for looking into that and letting me know! – Jen Person Jun 22 '17 at 18:08
3
func authUI(_ authUI: FUIAuth, didSignInWith user: User?, error: Error?) {
    print("")
}

Replace this with

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

If there is another User class defined it can cause conflict. By replacing User -> FirebaseAuth.User, we are just specifying exactly which user class should be used.

Sameer
  • 201
  • 2
  • 4