12

I was following this tutorial to add google sign in in my iOS app using swift. I followed all the steps as mentioned but when I try to build app then it is giving me an issue in my appdelegate.swift file.

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

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

    GIDSignIn.sharedInstance().clientID = "client id"

    return true

}

so below line of code

GGLContext.sharedInstance().configureWithError(&configureError)

Error text is "Use of unresolved identifier GGLContext". What could be the issue here ?

3
  • One more thing i am adding google signin in my existing app so i am not using pod just manual files integration as given in tutorial Commented Jul 25, 2015 at 12:58
  • I am also facing the same issue. Followed tutorial from google developers siten developers.google.com/identity/sign-in/ios/start-integrating . And I think there's something missing in that tutorial for those who are integrating without pods. Did you find the solution? Commented Nov 30, 2015 at 3:52
  • What is Google doing? they even cannot write a tutorial correctly! Commented Oct 30, 2017 at 22:32

4 Answers 4

5

in Bridging-Header.h

import <GoogleSignIn/GoogleSignIn.h>

import <Google/Core.h>

in AppDelegate.swift

import Google
Sign up to request clarification or add additional context in comments.

4 Comments

This seems to no longer work with GoogleSignIn 4.0.0, I'm seeing 'Google/Core.h' file not found
^ The version was actually not the issue at all, it should have been clear my issue was unrelated bc cocoapod frameworks don't need a bridging header. Just in case someone else ends up on this question when installing with Cocoapods: There is a pod named GoogleSignIn which was what I included, but this is the wrong thing and doesn't have all the necessary dependencies. You need to install Google/SignIn which depends on the Google framework (as well as a bunch of seemingly unrelated cruft like FirebaseCore and FirebaseAnalytics). Using the right pod the docs instructions are correct.
@danny "Using the right pod the docs instructions are correct."... Google has documentation saying to use both. Finding the right documentation for this is extremely difficult.
github.com/googlesamples/google-services/blob/master/ios/signin/… shows that "var configureError: NSError?; GGLContext.sharedInstance().configureWithError(&configureError);" isn't even needed
2

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

Comments

1

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.

Comments

0

in swift, the below worked for me.

import GoogleSignIn

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.