Open fikus opened 7 years ago
I just ran into an issue with the docs. The import doesn't work, https://developers.google.com/analytics/devguides/collection/ios/v3/?ver=swift
However, the Swift example in this project does work. The documentation should reflect the correct imports in the bridging header file from the example. https://github.com/googlesamples/google-services/blob/master/ios/analytics/AnalyticsExampleSwift/BridgingHeader.h#L19-L21
@ulukaya can you take a look at this?
Bumping this
Due to the change from Google/SignIn
to GoogleSignIn
, this is currently inaccurate:
https://developers.google.com/identity/sign-in/ios/sign-in?ver=swift
The import should be
#import <GoogleSignIn/GoogleSignIn.h>
and not
#import <Google/SignIn.h>
Issue is still present - Documentation is inconsistent, still tells you to use the old import:
#import <Google/SignIn.h>
Also goes on to reference GGLContext
which is results a unresolved identifier error.
Haven't found a workaround, yet.
EDIT
Workaround here
@VariableDeclared Are you able to detail an implementation? I'm still being thrown the same error from the linked workaround.
@rhys-edwards here:
Contents of my bridging-header ([APP]-Bridging-Header.h):
#import <GoogleSignIn/GoogleSignIn.h>
file import statement:
import GoogleSignIn
EDIT
Apologies, referred back to workaround to refresh context, my app delegate has the following:
let path = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist")
let googleService = NSDictionary(contentsOfFile: path!)!
GIDSignIn.sharedInstance().clientID = googleService.object(forKey: "CLIENT_ID") as! String
GIDSignIn.sharedInstance().delegate = self
return true
As per the workaround, so difference being the missing GIDSignIn.sharedInstance().uiDelegate = self
, which done in the viewDidLoad
of the view controller file, struggling to recall my fix, but if I recall correctly the above import statements were the root of my problem,
Anything else, lemme know.
@VariableDeclared Thanks. I've already got that in there. Can you spot anything wrong in my appdelegate below?
import UIKit
import GoogleSignIn
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {
var window: UIWindow?
// Did Finished Launching
func application (_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let path = Bundle.main.path(forResource: "GoogleService-Info", ofType: "plist")
let googleService = NSDictionary(contentsOfFile: path!)!
GIDSignIn.sharedInstance().clientID = googleService.object(forKey: "CLIENT_ID") as! String
GIDSignIn.sharedInstance().delegate = self
// Init Sign in
// GIDSignIn.sharedInstance().clientID = "302427320393-t6bu15lpgp6qol949tci68lgvcfjld4m.apps.googleusercontent.com"
// GIDSignIn.sharedInstance().delegate = self
return true
}
// Open URL
func application (_app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any]) -> Bool {
return GIDSignIn.sharedInstance().handle(url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation])
}
public func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) {
if let error = error {
print("\(error.localizedDescription)")
NotificationCenter.default.post(
name: Notification.Name(rawValue: "ToggleAuthUINotificiation"), object: nil, userInfo: nil)
} else {
// User Stuff
let userID = user.userID
let idToken = user.authentication.idToken
let fullName = user.profile.name
let givenName = user.profile.givenName
let familyName = user.profile.familyName
let email = user.profile.email
NotificationCenter.default.post(
name: Notification.Name(rawValue: "ToggleAuthUINotification"),
object: nil,
userInfo: ["statusText": "Signed in user:\n\(fullName)"])
}
}
public func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, withError error: Error!) {
// Disconnect the user
NotificationCenter.default.post(
name: Notification.Name(rawValue: "ToggleAuthUINotification"),
object: nil,
userInfo: ["statusText": "User has disconnect."])
}
}
@rhys-edwards, apologies, kept updating my above comment.
But the immediate difference I can spot here is the uiDelegate, which was assigned in my app in the ViewController for the appropriate view:
viewDidLoad()
:
GIDSignIn.sharedInstance().uiDelegate = self
That's pretty much the contents of the function.
The documentation at https://developers.google.com/identity/sign-in/ios/ (for example) needs to be updated to show that the
Google
pod is deprecated and provide working sample code for the new structure.