Migrate from a Google Project on iOS

At Google I/O 2016, we announced Firebase - a new toolkit for building mobile apps. Firebase replaces several existing Google developer technologies, and adds many new services. This guide walks you through the process of updating your apps from projects created using the existing setup tool or Google API console.

You can learn more about Firebase in our documentation. If you're upgrading from an existing Firebase.com project, please see our upgrade guide. If you have trouble migrating, reach out to our developer support.

Migrate your console project

Firebase manages all of your API settings and credentials through a single configuration file. The file is named google-services.json on Android and GoogleService-Info.plist on iOS. It can be downloaded by following the steps below.
  • Add Firebase to a Google Developer Project Go to Firebase console and select Import Google Project.
  • Select an existing project.
  • If using App Invites, select the Dynamic Links panel and accept the warning. This enables Firebase Invites.
  • Configure your project in Firebase:
    1. Click the cog in the left hand menu, and select Project Settings.
    2. For each of your iOS apps, select them and add your app store ID and team ID.
    3. For each app in your project, download updated google-service.json or GoogleService-Info.plist files from the Firebase console. This will contain required information for Google Analytics, Cloud Messaging, and Google Sign In.

Update your Cocoapods configuration

Most services have moved to the Firebase pod from the Google pod, but Google/SignIn and Google/Analytics are unchanged. You'll need to update your Podfile as below.

Old Dependency New Dependency
Google/Core pod 'Firebase/Core'
Google/SignIn Google/SignIn
Google/Analytics Google/Analytics
Google/CloudMessaging pod 'Firebase/Messaging'
Google/AppInvite pod 'Firebase/Invites'
Google/AdMob pod 'Firebase/AdMob'

Configuring the Firebase SDK

You'll need to update the configuration code used in your AppDelegate from the Google pod version to the Firebase pod version. This will configure both the Firebase and Google pod libraries.

BEFORE
  1. Import the Firebase header file.

    Swift

    // In Bridging header.
    #import <Google/YOUR_SERVICE.h>
    

    Objective-C

    #import <Google/YOUR_SERVICE.h>
    
  2. Swift

    var configureError:NSError?
    GGLContext.sharedInstance().configureWithError(&configureError)
    assert(configureError == nil, "Error configuring Google services: \(configureError)")
    

    Objective-C

    NSError* configureError;
    [[GGLContext sharedInstance] configureWithError:&configureError];
    NSAssert(!configureError, @"Error configuring Google services: %@", configureError);
    
AFTER
  1. Import the Firebase module in your UIApplicationDelegate subclass:

    Swift

    import Firebase
    

    Objective-C

    @import Firebase;
    
  2. Configure a FIRApp shared instance, typically in your application's application:didFinishLaunchingWithOptions: method:

    Swift

    // Use Firebase library to configure APIs
    FirebaseApp.configure()
    

    Objective-C

    // Use Firebase library to configure APIs
    [FIRApp configure];
    

Upgrade Google App Invites to Firebase Invites

Update your Podfile.

BEFORE
pod 'Google/AppInvite'
AFTER
pod 'Firebase/Invites'

Update the Invites receiving code

In your AppDelegate in the application:didFinishLaunchingWithOptions method:

BEFORE

Swift

GINInvite.applicationDidFinishLaunching()

Objective-C

  [GINInvite applicationDidFinishLaunching];
AFTER

Swift

FIRInvites.applicationDidFinishLaunchingWithOptions(launchOptions)

Objective-C

  [FIRInvites applicationDidFinishLaunchingWithOptions:launchOptions];

Still in the AppDelegate in the application:openURL:sourceApplication:annotation: method

BEFORE

Swift

 let invite = GINInvite.handleURL(url, sourceApplication:sourceApplication, annotation:annotation)

      if (invite != nil) {
        GINInvite.completeInvitation()
        let matchType =
            (invite.matchType == GINReceivedInviteMatchType.Weak) ? "Weak" : "Strong"
         // ... process invite.

Objective-C

GINReceivedInvite *invite = [GINInvite handleURL:url
                                 sourceApplication:sourceApplication
                                        annotation:annotation];
  if (invite) {
    [GINInvite completeInvitation];
    NSString *matchType =
        (invite.matchType == kGINReceivedInviteMatchTypeWeak) ? @"Weak" : @"Strong";
    // ... process invite
AFTER

Swift

if let invite = FIRInvites.handleURL(url, sourceApplication:sourceApplication, annotation:annotation) as? FIRReceivedInvite {
        let matchType =
            (invite.matchType == FIRReceivedInviteMatchType.Weak) ? "Weak" : "Strong"
            // ... process invite

Objective-C

FIRReceivedInvite *invite =
      [FIRInvites handleURL:url sourceApplication:sourceApplication annotation:annotation];
  if (invite) {
    NSString *matchType =
        (invite.matchType == FIRReceivedInviteMatchTypeWeak) ? @"Weak" : @"Strong";
    // ... process invite.
  }

Update the Invites sending code

Update the protocol your UIViewController implements

BEFORE
GINInviteDelegate
AFTER
FIRInviteDelegate

The actual callback method is unchanged.

Send the invite

BEFORE

Swift

GINInvite.inviteDialog()

Objective-C

[GINInvite inviteDialog];
AFTER

Swift

FIRInvites.inviteDialog()

Objective-C

[FIRInvites inviteDialog];

Upgrade AdMob by Google

Update your CocoaPods dependencies.

BEFORE
pod 'Google/AdMob'
AFTER
pod 'Firebase/AdMob'

No code changes are required.

Upgrade Google Cloud Messaging (GCM) to Firebase Cloud Messaging (FCM)

You can continue to use your existing GCM integration, but if you want to take advantage of the Notifications composer GUI, you will need to update to FCM: see our full guide to upgrading your iOS GCM app to use FCM.

Send feedback about...

Need help? Visit our support page.