Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIDSignIn.sharedInstance : sharedInstance not a function?

In this code, when I type GIDSignIn.sharedInstance, for some reason sharedInstance is not a function, which means I can't acces clientID. I cannot find a solution for this anywhere.

import UIKit
import GoogleSignIn


@main

class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
GIDSignIn.sharedInstance().clientID = "clientID"
        
          return true
    }
like image 794
Kavya Khurana Avatar asked Oct 20 '25 04:10

Kavya Khurana


2 Answers

In latest version of GoogleSignIn SDK. Removed this method.

Now in new follow this link or below code. https://developers.google.com/identity/sign-in/ios/sign-in

@IBAction func clkLoginWithGmail(_ sender: UIButton) {
     let signInConfig = GIDConfiguration.init(clientID: "clientID-XYZ")
     GIDSignIn.sharedInstance.signIn(with: signInConfig, presenting: self) { user, error in

     }
}
like image 106
Nikunj Gangani Avatar answered Oct 22 '25 18:10

Nikunj Gangani


There is a change in the dependency.

GIDSignIn.sharedInstance.clientID

Has been changed to:

GIDConfiguration(clientID: "clientID", serverClientID: "serverClientID")

And can be used in your class or AppDelegate.swift

import GoogleSignIn

let gIdConfiguration = GIDConfiguration(clientID: "clientID", serverClientID: "serverClientID")

GIDSignIn.sharedInstance.configuration = gIdConfiguration
like image 29
Benjamin Inemugha Avatar answered Oct 22 '25 17:10

Benjamin Inemugha



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!