iOS Swift : error with google login
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 Bridging-Header.h
import <GoogleSignIn/GoogleSignIn.h>
import <Google/Core.h>
in AppDelegate.swift
import Google
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.