我正在尝试在 swift-3 中实现 Google Signin,但我遇到了一个非常奇怪的错误我正在点击链接 developers.google/identity/sign-in/ios/sign-in?ver=swift.但是每次我一次又一次地执行它时,我都会看到这个错误.我在桥接头中添加了以下内容.
I am Trying to implement Google Signin in swift-3 but I am having a very strange error I am following the link developers.google/identity/sign-in/ios/sign-in?ver=swift . But I see this error everytime I do Implement it again and again. I have added the following in bridging header.
#import <Google/SignIn.h>我已经安装了 pod GoogleSignin pod 'Google/SignIn'
I have installed the pod GoogleSignin pod 'Google/SignIn'
这是我的 AppDelegate 文件代码
This is my AppDelegate File code
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'
'AppDelegate' does not conform to protocol 'GIDSignInDelegate'
我试过重新安装 pods
I 've tried reinstalling pods
我尝试过清洁和其他事情,但没有注意到有帮助.
I've tried cleaning and other things but nope noting helped.
推荐答案我刚刚花了 3 个小时解决这个问题.您需要实现的正确签名是:
I just spent 3 hours on this. The correct signature you need to implement is :
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!)
但是 - 检查您是否没有覆盖应用中Error 的定义(或其他类GIDSignIn、GIDGoogleUser).我的应用程序中有一个自定义的 Error 类,它覆盖了默认的 Error 类.在我重命名我的 Error 类后,问题就消失了.
But - check whether you are not overriding the definition of Error in your app (or the other classes GIDSignIn, GIDGoogleUser). I had a custom Error class in my app which has overridden the default Error class. After I renamed my Error class, the problem went away.
Swift 编译器在这里不是很有帮助,因为它在错误消息中将两种情况的类型都显示为 Error,而没有指出它们都表示不同的 Error 类型.
Swift compiler was not very helpful here, because it displayed the type as Error for both cases in the error message, while not indicating they both mean different Error types.
教训是不要将 Foundation 中已经使用的名称用于我的课程.
The lesson is to not use names already used in Foundation for my classes.
更多推荐
“AppDelegate"不符合协议“GIDSignInDelegate"
发布评论