'AppDelegate'不符合协议'GIDSignInDelegate'
我试图在swift-3中实现Google Signin,但是我有一个非常奇怪的错误,我正在关注链接https://developers.google.com/identity/sign-in/ios/sign-in?ver=swift 。 但是我每次都会看到这个错误。 我在桥头添加了以下内容。
#import <Google/SignIn.h>
我已安装pod GoogleSignin pod'Google pod 'Google/SignIn'
这是我的AppDelegate文件代码
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate { //<--Here it gives the error //Method implemented but giving the error func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) { //TODO } }
'AppDelegate'不符合协议'GIDSignInDelegate'
我试过重新安装豆荚
我已经尝试清洗和其他的东西,但没有注意到帮助。
我只花了3个小时。 您需要实现的正确签名是:
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!)
但是 – 检查你是否不覆盖你的应用程序 (或其他类GIDSignIn
, GIDGoogleUser
)中的Error
的定义 。 我有一个自定义Error
类,在我的应用程序已覆盖默认的Error
类。 我重命名我的Error
类后,问题就消失了。
Swift编译器在这里并不是很有帮助,因为它在错误信息中显示了两种情况下的Error
types,而没有指出它们都是不同的Error
types。
这个教训是不要使用已经用于基础课程的名字。
您需要在appdelegate中添加以下两个方法
func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, withError error: Error!) { } func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) { }
您必须执行所有必需的GIDSignInDelegate
方法才能删除此错误。 所以检查GIDSignInDelegate
协议中的方法列表,并在AppDelegate类中实现。
并在didFinsishLaunchingOption
方法设置委托为:
GIDSignIn.sharedInstance().delegate = self
这是一个非常愚蠢的错误,我在我的代码中有一个名为Error的自定义类,它引发了这个问题,因为GidSignInDelegate方法无法识别引用哪个错误类。 任何寻找答案,如果你犯了同样的愚蠢的错误,请交叉检查。
- 不能使用UnsafeMutableRawPointertypes的参数列表调用types为UnsafePointer <_>的初始值设定项。
- Xamarin iOS ZXing条码阅读使用前置摄像头的问题
- 屏幕locking时HealthStore enableBackgroundDelivery
- 在iOS中使用钥匙串存储的密钥生成OpenSSL证书签名请求
- 使用ios中的Google Map sdk从GMSMapview中删除特定的GMSMarker
- 更改导航栏iOS Swift的高度
- Cordova + Crosswalk iOS仍在使用UIWebView
- PhoneGap / Apache Cordova提出了一个用于encryptionSQLite数据库的API
- Swift类扩展 – 无法识别的select器发送到实例
- redirect到应用程序,如果安装,否则到App Store
- iOS上的StoreKit – 自动更新的订阅 – 如何知道它是否免费试用?