iOS Swift : error with google login

左心房为你撑大大i 提交于 2019-12-01 15:22:20

I found the solution, You can use the Bridge-Header.h file and import like that

#ifndef Bridge_header_h
#define Bridge_header_h

#import "Google/Core.h"
#import "GoogleSignIn.h"

#endif /* Bridge_header_h */

it's work perfectly at my end.

Dattatray Deokar

in Bridging-Header.h

import <GoogleSignIn/GoogleSignIn.h>

import <Google/Core.h>

in AppDelegate.swift

import Google

Preliminary:

I have been annoyed for a few days now that when I integrated the Cocoapod Google/SignIn that I was getting Thread warnings. After digging into everything, I may have found a solution. This probably would only be something worth looking at if the only aspect of google you want in your project in sign in. If you have Firebase or any other part of google integrated, you probably will never hit an issue that leads you to this thread though.

OK, after delving into this problem for a bit, I found my solution to be:

In Bridging Header import only #import <GoogleSignIn/GoogleSignIn.h>

In AppDelegate import only import GoogleSignIn

In Podfile import only pod 'GoogleSignIn'

In AppDelegate didFinishLaunchingWithOptions do domething like this:

if let path = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist"),
    let googleInfo = NSDictionary(contentsOfFile: path),
    let clientId = googleInfo["CLIENT_ID"] as? String {
    GIDSignIn.sharedInstance().clientID = clientId
}
GIDSignIn.sharedInstance().delegate = self

and remove:

var configureError: NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError!)")

With this setup, everything seems to be working great. I got the idea by looking at the link below. Let me know if this works for you.

https://github.com/googlesamples/google-services/blob/master/ios/signin/SignInExampleSwift/AppDelegate.swift

in swift, the below worked for me.

import GoogleSignIn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!