Uncaught NSInvalidArgumentException when using Google Sign In for iOS

7.7k views Asked by At

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?

4

There are 4 answers

0
class On BEST ANSWER

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...

1
Deepak Chaudhary On

Once go through with this : Here you'll get all about URL Scheme problem

Add the configuration file to your project

Drag the GoogleService-Info.plist file you just downloaded into the root of your Xcode project and add it to all targets. Add URL schemes to your project

Google Sign-in requires two custom URL Schemes to be added to your project. To add the custom schemes:

Open your project configuration: 
1. double-click the project name in the left tree view. Select your app from the TARGETS section, 
2. then select the Info tab, and expand the URL Types section.
3. Click the + button, and add a URL scheme for your reversed client ID. 
To find this value, open the GoogleService-Info.plist configuration file,
4. and look for the REVERSED_CLIENT_ID key. Copy the value of that key, 
5. and paste it into the URL Schemes box on the configuration page. 
Leave the other fields blank.
6. Click the + button, and add a second URL scheme. 
This one is the same as your app's bundle ID. 
For example, if your bundle ID is com.example.app, 
7. type that value into the URL Schemes box. 
8. You can find your app's bundle ID in the General tab of the project configuration (Identity > Bundle Identifier).
3
Olivier Albertini On

Wait ! Update iOS 9+

In iOS 9 you must whitelist any URL schemes your App wants to query in Info.plist under the LSApplicationQueriesSchemes key (an array of strings)

so you need to add under LSApplicationQueriesSchemes, your bundle id and the reverse id in Google-ServiceInfo.

I search for a long time and google doc doesn't mention it yet ...

my app crashed everytime in appDelegate until I add these lines in info.plist...

0
Teddy On

Starting from iOS9 you have to set 4 (four) values to your info.plist file.

URL Types

  • Select your target app in Project Settings
  • Select info on top bar
  • Scroll down to URL Types
  • Add a URL type
  • Fill out URL Schemes using the REVERSED_CLIENT_ID key from your GoogleService-Info.plist file, leave other fields as they are
  • Add a 2nd URL type, this time with your application bundle id from General tab

LSApplicationQueriesSchemes

  • Add a new Target Property named LSApplicationQueriesSchemes. Should be a type of array.
  • Add one item equal to the REVERSED_CLIENT_ID value
  • Add a second item with your app bundle id again

Compile and enjoy.