You must specify |clientID| for |GIDSignIn| error when trying to sign in with Google

Daniel Que picture Daniel Que · Sep 27, 2016 · Viewed 11.8k times · Source

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

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

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

It seems the CLIENT_ID isn't being fetched from GoogleService-Info.plist. I've made sure it's in the Copy Bundle Resources.

enter image description here

I shouldn't have to specify the client id in the code. How can I fix it to get the information from the GoogleService-Info.plist file?

Answer

Donal picture Donal · Feb 14, 2017

You can do it this way.

Swift:

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

Objective-C:

GIDSignIn.sharedInstance.clientID = FIRApp.defaultApp.options.clientID;