Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use of unresolved identifier 'GGLContext'

I am integrating Google Sign-In in my ios Swift app. I am following the official instructions on the google developer page here(https://developers.google.com/identity/sign-in/ios/sign-in?ver=swift )

Here is my Bridging Header:

#ifndef Header_h
#define Header_h


#endif /* Header_h */

#import <CommonCrypto/CommonCrypto.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#import <GoogleSignIn/GoogleSignIn.h>

When I call the line in my AppDelegate.swift function that has

    GGLContext.sharedInstance().configureWithError(&configureError)

in it. It says

 Use of unresolved identifier 'GGLContext'

Any help is appreciated.

like image 456
Thalatta Avatar asked Sep 02 '16 18:09

Thalatta


3 Answers

Google/* pods are deprecated, you should use pod GoogleAnalytics or pod GoogleSignIn instead. You can't find GGLContext in those pods because it no longer exists since it no longer requires a GoogleInfo-Service.plist file for Analytics or SignIn.

For SignIn you should use the clientID that was previously obtained in the GoogleInfo-Service.plist file to initialize

GIDSignIn.sharedInstance().clientID = kClientID

or if you are using Firebase

GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID

For Analytics you should use the trackerID that was previously obtained in the GoogleInfo-Service.plist file or in the analytics panel to initialize

let tracker = GAI.sharedInstance().tracker(withTrackingId: kTrackerID)

Google SignIn docs

Google Analytics docs

like image 159
Benjamin Jimenez Avatar answered Oct 16 '22 10:10

Benjamin Jimenez


Inside Podfile.h,

replace

pod 'GoogleSignIn' 

with

pod 'Google/SignIn'

Inside BridgingHeader.h file add the following two lines:

#import <GoogleSignIn/GoogleSignIn.h>
#import <Google/Core.h>

Inside AppDelegate.swift,

replace

import GoogleSignIn

with

import Google

This worked in my case.

Actually the pod 'Google/SignIn' has the required dependencies of Google needed to use GGLContext. These aren't present when installing cocoapods using pod 'GoogleSignIn'

like image 21
Saurabh Bhatia Avatar answered Oct 16 '22 09:10

Saurabh Bhatia


The answer of Benjamin Jimenez was the correct one, not the one marked as "correct" since it suggests to use deprecated version of libraries instead of moving on with the new versions and updating your project accordingly: https://stackoverflow.com/a/46858690/3506788

One small addition to the solution though: if you use Firebase, make sure that you initialise Firebase before using this line:

GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID
like image 4
Toka Avatar answered Oct 16 '22 08:10

Toka