Firebase iOS-类型"LoginViewController"不符合协议"FUIAuthDelegate" [英] Firebase iOS - Type 'LoginViewController' does not conform to protocol 'FUIAuthDelegate'
问题描述
我正在将Firebase Auth UI集成到我的应用程序中,由于某种原因,我一直收到此错误:
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'
在您开始不屑一顾我之前,我保证我不是白痴. 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?
然后这个:
Candidate has non-matching type '(FUIAuth, User?, Error?) -> ()'
问题是,我的类中已经包含了该函数,而且我相当确定自己遵守了协议……这是ViewController的代码:
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?
推荐答案
从LoginViewController扩展中删除FUIAuthDelegate
协议:
Remove the FUIAuthDelegate
protocol from the LoginViewController extension:
extension LoginViewController {
func authUI(_ authUI: FUIAuth, didSignInWith user: User?, error: Error?) {
print("")
}
}
我刚刚确认,当我在自己的应用程序中添加FUIAuthProtocol
时,遇到了与您看到的相同的错误.没有它,它运行良好.
I just confirmed that when I added FUIAuthProtocol
to my own app, I got the same error you saw. Without it, it runs fine.
这篇关于Firebase iOS-类型"LoginViewController"不符合协议"FUIAuthDelegate"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!