sgammon sgammon - 1 year ago 377
iOS Question

Uncaught NSInvalidArgumentException when using Google Sign In for iOS

I tried today to upgrade to Google Sign In for iOS (we have an existing app built against Google+ Sign In).

I followed the getting started guide to build the configuration out, and added my proper URL schemes (for instance, the app's client ID).

Upon launching the app and attempting sign in with Google, I get the following uncaught exception:

2015-06-09 03:43:23.800 <appname>[238:7171] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason:
'Your app must support the following URL schemes: (null)'

The exception occurs outside of our control, between GIDSignIn.signIn and GIDSignIn.delegate.signIn.

Is there anything I can do to fix this?

Answer Source

What's going on is that the Google SDK is retrieving your client configuration from the dictionary in GoogleService-Info.plist but it most likely is not finding any configurations or is not able to find the file.

When you call [[GGLContext sharedInstance] configureWithError: .., e.g.:

NSError* configureError;
[[GGLContext sharedInstance] configureWithError: &configureError];

The code parses your client ID from the Google-ServiceInfo.plist file, which you should add to a supporting files or other shared resources folder, and then checks that you have also added a URI for the reversed client ID, which is pulled from the plist dictionary.

First of all, if you don't have this file, generate it by following the wizard on the new Enable Google services for your app page.

Next, make sure that you're copying the GoogleService-Info.plist file as a resource in your Xcode project in the build phases section. When you have successfully added it to your project (usually best added in a Shared Resources section) the error message will no longer indicate a null URI is required.

Finally, make sure that you have added the bundle ID and reversed client ID in your application's URLs - which should be easy to do because the error message will tell you what's missing at this point.

If all this is still giving you trouble, you might want to try Google Sign-In for iOS using the quickstart sample by running:

pod try Google

And starting from the SignInExample.xcodeproject sample...