大佬教程收集整理的这篇文章主要介绍了Firebase iOS Google登录 – 使用未声明的类型GIDSignInDelegate,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
按照指南(在链接中)我到处都是这个错误,使用未声明的类型GIDSignInDelegate@H_673_7@
例如,在AppDelegate类声明中……@H_673_7@
class AppDelegate:UIResponder,UIApplicationDelegate,UISplitViewControllerDelegate,GIDSignInDelegate {@H_673_7@
我在类声明中看到了其他类型,例如UIResponder和UIApplicationDelegate.这些类型在哪里定义?@H_673_7@
我猜我只是缺少类型定义.@H_673_7@
我创建了一个头文件Basketball-Vision-Bridging-Header.h并导入#import< GoogleSignIn / GoogleSignIn.h>@H_673_7@
pod 'Firebase' pod 'Firebase/Auth' pod 'GoogleSignIn'
我发现我错过了这些依赖项:@H_673_7@
import Google import GoogleSignIn
但是现在当我导入这些时,我得到错误类型’AppDelegate’不符合协议’GIDSignInDelegate’@H_673_7@
import UIKit import Firebase import Google import GoogleSignIn @UIApplicationMain class AppDelegate: UIResponder,GIDSignInDelegate { var window: UIWindow? func signIn(signIn: GIDSignIn!,didSignInForUser user: GIDGoogleUser!,withError error: NSError!) { if let error = error { print(error.localizedDescription) return } // ... } func signIn(signIn: GIDSignIn!,didDisconnectWithUser user:GIDGoogleUser!,withError error: NSError!) { // Perform any operations when the user disconnects from app here. // ... } func application(application: UIApplication,didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Use Firebase library to configure APIs FIRApp.configure() GIDSignIn.sharedInstance().clientID = FIRApp.defaultApp()?.options.CLIENtID GIDSignIn.sharedInstance().delegate = self return true } openURL url: NSURL,options: [String: AnyObject]) -> Bool { return GIDSignIn.sharedInstance().handleURL(url,sourceApplication: options[UIApplicationOpenURLOptionssourceApplicationKey] as? String,Annotation: options[UIApplicationOpenURLOptionsAnnotationKey]) } openURL url: NSURL,sourceApplication: String?,Annotation: AnyObject?) -> Bool { var options: [String: AnyObject] = [UIApplicationOpenURLOptionssourceApplicationKey: sourceApplication,UIApplicationOpenURLOptionsAnnotationKey: Annotation] return GIDSignIn.sharedInstance().handleURL(url,sourceApplication: sourceApplication,Annotation: Annotation) } // func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // // Override point for customization after application launch. // let splitViewController = self.window!.rootViewController as! UISplitViewController // let navigationController = splitViewController.viewControllers[splitViewController.viewControllers.count-1] as! UINavigationController // navigationController.topViewController!.navigationItem.leftBarButtonItem = splitViewController.displaymodeButtonItem // splitViewController.delegate = self // return true // } func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS messagE) or when the user quits the application and it begins the transition to the BACkground state. // Use this method to pause ongoing tasks,disable timers,and invalidate graphics rendering callBACks. Games should use this method to pause the game. } func applicationDidEnterBACkground(_ application: UIApplication) { // Use this method to release shared resources,save user data,invalidate timers,and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports BACkground execution,this method is called instead of applicationWillTerminate: when the user quits. } func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the BACkground to the active state; here you can undo many of the changes made on entering the BACkground. } func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was prevIoUsly in the BACkground,optionally refresh the user interface. } func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBACkground:. } // MARK: - Split view func splitViewController(_ splitViewController: UISplitViewController,collapseSecondary secondaryViewController:UIViewController,onto priMaryViewController:UIViewController) -> Bool { guard let secondaryAsNavController = secondaryViewController as? UINavigationController else { return false } guard let topAsDetailController = secondaryAsNavController.topViewController as? DetailViewController else { return false } if topAsDetailController.detailItem == nil { // Return true to inDicate that we have handled the collapse by doing nothing; the secondary controller will be discarded. return true } return false } }
func sign(_ signIn: GIDSignIn!,didSignInFor user: GIDGoogleUser!,withError error: Error!) { if error != nil { print("Google Sign In Error") } else { // Do stuff } }
openURL,didFinishLaunchingWithOptions和didDisconnectWithUser在Swift 3.0中也发生了变化.我建议你重新实现它们.@H_673_7@
以上是大佬教程为你收集整理的Firebase iOS Google登录 – 使用未声明的类型GIDSignInDelegate全部内容,希望文章能够帮你解决Firebase iOS Google登录 – 使用未声明的类型GIDSignInDelegate所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。