You must specify | clientID | for | GIDSignIn | when trying to log in using google

Logging in to Google worked fine with Xcode 7. After upgrading to Xcode 8, I started getting an error: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'You must specify |clientID| for |GIDSignIn|' Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'You must specify |clientID| for |GIDSignIn|' . I have a GoogleService-Info.plist file with my identifier CLIENT_ID.

I was able to fix this by adding the following line:

 GIDSignIn.sharedInstance().clientID = "<CLIENT_ID>" 

It seems that CLIENT_ID is not being retrieved from GoogleService-Info.plist. I made sure that this is in the Bundle Copy Resources.

enter image description here

I do not need to specify the client identifier in the code. How can I fix this to get information from the GoogleService-Info.plist file?

+9
source share
7 answers

You can do it this way.

Swift:

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

Goal-C :

 GIDSignIn.sharedInstance.clientID = FIRApp.defaultApp.options.clientID; 
+11
source

Please make sure you have the code in sequence.

 FirebaseApp.configure() GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID GIDSignIn.sharedInstance().delegate = self 

FirebaseApp.app()?.options.clientID will be able to receive data from GoogleService-Info.plist after calling FirebaseApp.configure() .

+4
source

I had the same problem. In fact, GoogleServices-Info.plist been updated in my case. I GoogleServices-Info.plist and updated it with the old one that fixed this problem for me.

+1
source

I solve it by adding forgotten code to the AppDelegate class:

 #import "AppDelegate.h" #import <Google/SignIn.h> @interface AppDelegate ()<GIDSignInDelegate> @end @implementation AppDelegate #pragma mark - UIApplicationDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //Google sign-in setup NSError* configureError; [[GGLContext sharedInstance] configureWithError: &configureError]; if (configureError) { NSLog(@"Error configuring Google services: %@", configureError.localizedDescription); } [GIDSignIn sharedInstance].delegate = self; return YES; } #pragma mark - GIDSignInDelegate - (void)signIn:(GIDSignIn *)signIn didSignInForUser:(GIDGoogleUser *)user withError:(NSError *)error { //add your code here } - (void)signIn:(GIDSignIn *)signIn didDisconnectWithUser:(GIDGoogleUser *)user withError:(NSError *)error { //add your code here } @end 
+1
source

quick 3 in appdelegate add:

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

If you came here using Google SignIn from Xamarin on iOS, then you probably need to install Client Id specifically for the shared SignIn instance for the rest of the process to work. I have a class for managing callbacks for Google iOS authentication in which I am making the following code:

 SignIn.SharedInstance.ClientID = "[Client Id Here].apps.googleusercontent.com"; SignIn.SharedInstance.Delegate = this; SignIn.SharedInstance.UIDelegate = this; SignIn.SharedInstance.SignInUser(); 

I would recommend explicitly specifying this client identifier in the configuration, although I assumed that he would simply select the client identifier from the GoogleServices-Info.plist gift, but that is not the case.

I also have GoogleServices-Info.plist in the Resources folder, where BundledResource is installed for the assembly, and I downloaded it from the Google Developer Console for my application and then renamed it “GoogleServices-Info.plist” from a rather long own name . Finally, it’s also worth noting that I set the “Entitlements.plist” option specifically on the “iOS Package Signing” page in the “User Rights” section, which avoids the keychain error that you will inevitably see. Do not forget to also "Enable the keychain" in the rights themselves.

0
source

Despite doing everything that my application crashed by touching GIDSignInButton . In my case, I moved the ClientId installation code from AppDelegate to where the GIDSignInButton was stored (LoginViewController say).

 public override func viewDidLoad() { super.viewDidLoad() configureViews() GIDSignIn.sharedInstance().uiDelegate = self GIDSignIn.sharedInstance().delegate = self GIDSignIn.sharedInstance().clientID = "Your_ClientID" } 
0
source

Source: https://habr.com/ru/post/1257344/


All Articles