Before you can begin integrating your iOS app with the Google Sign-In components, you must download the dependencies and configure your Xcode project. The steps on this page do just that. The next steps then describe how to integrate Google Sign-In features into your app.
Before you begin
Install a current version of Xcode.
Install the Google Sign-In dependencies in your project
If you don't already have CocoaPods installed, follow the steps in the CocoaPods Getting Started guide.
Open a terminal window and navigate to the location of your app's Xcode project.
If you have not already created a Podfile for your application, create one now:
Open the Podfile created for your application and add the following:
Save the file and run:
This creates an .xcworkspace file for your application. Use this file for all future development on your application.
Swift Package Manager
Open your project in Xcode.
Add the Google Sign-In dependencies to your app (Xcode documentation):
Version 6.0.2 Package GoogleSignIn
Get an OAuth client ID
Your app needs an OAuth client ID to identify itself to Google's authentication backend. If you haven't already created an OAuth client ID, click the button below to do so.
After you create the OAuth client ID, take note of the client ID string, which you will need to configure Google Sign-In in your app. You can optionally download the configuration file, which contains your client ID and other configuration data, for future reference.
If you already created an OAuth client ID, you can find your existing OAuth information by clicking the button below.
Get an OAuth server client ID
Most apps will need to pass the identity of signed-in users to a backend service of some kind. To securely pass the identity of users who signed in with Google to your backend, you use ID tokens, as discussed in Authenticate with a backend server. Retrieving a user's ID token requires a second client ID—your server client ID—which represents your backend.
To create a server client ID:
Open your project in the Cloud console.
Create a new Web application type OAuth client ID. Take note of the client ID string, which you will need to configure Google Sign-In in your app.
Add a URL scheme for Google Sign-In to your project
Google Sign-In requires a custom URL Scheme to be added to your project. To add the custom scheme:
Open your project configuration: double-click the project name in the left tree view. Select your app from the TARGETS section, then select the Info tab, and expand the URL Types section.
Click the + button, and add your reversed client ID as a URL scheme.
The reversed client ID is your client ID with the order of the dot-delimited fields reversed. For example:
When completed, your config should look something similar to the following (but with your application-specific values):
Now that you've downloaded the project dependencies and configured your Xcode project, you can add Google Sign-In to your iOS app.