Use our iOS sample app to see how Sign-In works, or add Sign-In to your existing app.
To use this sample, make sure you have Xcode and CocoaPods.
Get the project
Start with the sample using the following command from a terminal:
pod try GoogleSignIn
CocoaPods will clone the sample project from GitHub and open it in Xcode.
Get an OAuth client ID
Click the button below to create a new Google API project and get an iOS
client ID for the project. When prompted, specify
com
as the bundle ID.
After you create the OAuth client ID, copy it over the placeholder text in
AppDelegate.swift
:
GIDSignIn.sharedInstance().clientID = "YOUR_CLIENT_ID"
Set the callback URL type
Before Sign-In can run, you need to set up a URL type to handle the
callback. In your Xcode project's Info tab, under the URL Types
section, find the URL Schemes box containing the string
YOUR_REVERSED_CLIENT_ID
. Replace this string with your
reversed client ID—your client ID with the order of the
dot-delimited fields reversed. For example:
com.googleusercontent.apps.1234567890-abcdefg
Run the application
Now you're ready to build and run the sample app from Xcode.
Select the SignInExampleSwift target then start the sample application on a device or in the iOS simulator by clicking the run button for the workspace.

How it works
Add a GIDSignInButton
view to your app in a storyboard, a XIB file,
or programmatically. In the app delegate, implement the
signIn:didSignInForUser:withError
delegate method that will
be called when a user taps the sign-in button and completes the
sign-in flow.
func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error!) { if let error = error { if (error as NSError).code == GIDSignInErrorCode.hasNoAuthInKeychain.rawValue { print("The user has not signed in before or they have since signed out.") } else { print("\(error.localizedDescription)") } return } // Perform any operations on signed in user here. let userId = user.userID // For client-side use only! let idToken = user.authentication.idToken // Safe to send to the server let fullName = user.profile.name let givenName = user.profile.givenName let familyName = user.profile.familyName let email = user.profile.email // ... }
Next steps
If you want to see how you can implement Google Sign-In in your own app, take a look at our implementation guide.
Did you have a good experience? Run into trouble? Let us know!