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?
Remove the
FUIAuthDelegate
protocol from the LoginViewController extension:}
I just confirmed that when I added
FUIAuthProtocol
to my own app, I got the same error you saw. Without it, it runs fine.Replace this with
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.