14

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.

Thalatta
  • 4,510
  • 10
  • 48
  • 79

3 Answers3

33

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

Benjamin Jimenez
  • 984
  • 12
  • 26
21

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'

Saurabh Bhatia
  • 1,875
  • 1
  • 20
  • 29
4

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
Toka
  • 903
  • 7
  • 12
  • This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/low-quality-posts/17893176) – Toby Speight Nov 09 '17 at 15:41
  • 1
    It does provide a solution to the problem, more precisely a clarification to a comment that is the beginning of the solution. Also it points out that the post marked as "solution" is absolutely not one and a bad practice on top of that (edit: " _was_ marked as solution" since it has been changed since my first post). The system that prevents to comment an answer when the reputation is too low shows limits there in my opinion. That's not the topic of the discussion though. We can discuss about that privately instead of going of topic. – Toka Nov 13 '17 at 08:45
  • This comment was very helpful. – Benedikt Iltisberger Nov 26 '17 at 18:34