Skip to main content

iOS setup guide

warning

If you use Expo, follow this guide instead. This guide applies to vanilla React Native apps only.

  • run pod install in the ios/ directory to install the module

CocoaPods modular headers

Some dependency combinations may require modular headers. If pod install reports that the Swift pod AppCheckCore depends on GoogleUtilities or RecaptchaInterop, which do not define modules, add both pods to your existing application target in the Podfile:

ios/Podfile
target 'YourApp' do
pod 'GoogleUtilities', :modular_headers => true
pod 'RecaptchaInterop', :modular_headers => true

# The rest of your existing target configuration
end

Do not add version constraints to these declarations. CocoaPods will select versions compatible with Google Sign-In, and your other dependencies. Projects that already use use_modular_headers! or use_frameworks! do not need these additional declarations.

Google project configuration

  • Follow this guide to get the configuration information which you need for the next steps.

Firebase Authentication

If you're using Firebase Authentication, download the GoogleService-Info.plist file and place it into your Xcode project.

Xcode configuration

  • Configure URL types in the Info panel (see screenshot)
    • add your "iOS URL scheme" (also known as reversed client id), which can be found in Google Cloud Console under your iOS client ID.
  • If you need to support Mac Catalyst, you need to enable the Keychain Sharing capability on each build target. No keychain groups need to be added.

link config

Rebuild the native project

Do not forget to rebuild the native app after the setup is done.

Optional: modify your app to respond to the URL scheme

This is only required if you have multiple listeners for openURL - for instance if you have both Google and Facebook OAuth.

Because only one openURL method can be defined, if you have multiple listeners for openURL, you must combine them into a single function as shown below:

For AppDelegate written in Swift

If your AppDelegate a Swift file (the default in React Native 0.77.0 or higher), you'll need to:

  1. Add the following import to your project's bridging header file (usually ios/YourProject-Bridging-Header.h):
// …

// ⬇️ Add this import
#import <GoogleSignIn/GoogleSignIn.h>
  1. Modify your AppDelegate.swift file:
// …

@main
class AppDelegate: RCTAppDelegate {
// …

// ⬇️ Add this method
override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
// Add any other URL handlers you're using (e.g. Facebook SDK)
return ApplicationDelegate.shared.application(app, open: url, options: options) ||
GIDSignIn.sharedInstance.handle(url)
}

}

For AppDelegate written in Objective-C

For AppDelegate written in Objective-C (the default prior to React Native 0.77), modify your AppDelegate.m file:

#import "AppDelegate.h"
#import <GoogleSignIn/GoogleSignIn.h> // ⬅️ add the header import

// …

@implementation AppDelegate

// …

// ⬇️ Add this method before file @end
- (BOOL)application:(UIApplication *)application openURL:(nonnull NSURL *)url options:(nonnull NSDictionary<NSString *,id> *)options {
// Add any other URL handlers you're using (e.g. Facebook SDK)
return [[FBSDKApplicationDelegate sharedInstance] application:application openURL:url options:options] || [GIDSignIn.sharedInstance handleURL:url];
}

@end