Get Started with Premium Plan on iOS

Your Google Maps APIs Premium Plan license provides enhanced support for the Maps SDK for iOS. This document tells you how to create an iOS app that uses the Maps SDK for iOS with the Premium Plan.

Overview

Follow the instructions on this page to download the SDK, set up your project, and add a map. Here is a summary of the steps required:

  1. Install Xcode and the SDK.
  2. Get an API key.
  3. Add the API key to your app.
  4. Add a map.

Install Xcode and the SDK

Get the latest version of Xcode

To build a project using the Maps SDK for iOS, you need version 9.0 or later of Xcode.

Install the SDK

Use CocoaPods

The Maps SDK for iOS is available as a CocoaPods pod. CocoaPods is an open source dependency manager for Swift and Objective-C Cocoa projects.

If you don't already have the CocoaPods tool, install it on macOS by running the following command from the terminal. For details, see the CocoaPods Getting Started guide.

sudo gem install cocoapods

Create a Podfile for the Maps SDK for iOS and use it to install the API and its dependencies:

  1. If you don't have an Xcode project yet, create one now and save it to your local machine. (If you're new to iOS development, create a Single View Application.)
  2. Create a file named Podfile in your project directory. This file defines your project's dependencies.
  3. Edit the Podfile and add your dependencies. Here is an example which includes the dependencies you need for the Maps SDK for iOS and Places SDK for iOS (optional):
    source 'https://github.com/CocoaPods/Specs.git'
    target 'YOUR_APPLICATION_TARGET_NAME_HERE' do
      pod 'GoogleMaps'
      pod 'GooglePlaces'
    end

    Premium Plan customers must also add: pod 'GoogleMaps/M4B'.

  4. Save the Podfile.
  5. Open a terminal and go to the directory containing the Podfile:

    cd <path-to-project>
  6. Run the pod install command. This will install the APIs specified in the Podfile, along with any dependencies they may have.

    pod install
  7. Close Xcode, and then open (double-click) your project's .xcworkspace file to launch Xcode. From this time onwards, you must use the .xcworkspace file to open the project.

Install manually

This guide shows how to manually add the GoogleMaps framework to your project and configure your build settings in Xcode.

  1. Download the SDK source files: GoogleMaps-2.7.0.
  2. Unpack the source files.
  3. Launch Xcode and either open an existing project, or create a new project. If you're new to iOS, create a Single View Application, and disable Use Storyboards and enable Use Automatic Reference Counting.
  4. Drag the following bundles into your project (when prompted, select Copy items if needed):
    • GoogleMaps-2.7.0/Base/Frameworks/GoogleMapsBase.framework
    • GoogleMaps-2.7.0/Maps/Frameworks/GoogleMaps.framework
    • GoogleMaps-2.7.0/Maps/Frameworks/GoogleMapsCore.framework

    Premium Plan customers must also include GoogleMaps-2.7.0/M4B/Frameworks/GoogleMapsM4B.framework.

  5. Right-click GoogleMaps.framework in your project, and select Show In Finder.
  6. Drag the GoogleMaps.bundle from the Resources folder into your project. When prompted, ensure Copy items into destination group's folder is not selected.
  7. Select your project from the Project Navigator, and choose your application's target.
  8. Open the Build Phases tab, and within Link Binary with Libraries, add the following frameworks:
    • GoogleMapsBase.framework
    • GoogleMaps.framework
    • GoogleMapsCore.framework
    • GoogleMapsM4B.framework (Premium Plan customers only)
    • Accelerate.framework
    • CoreData.framework
    • CoreGraphics.framework
    • CoreImage.framework
    • CoreLocation.framework
    • CoreTelephony.framework
    • CoreText.framework
    • GLKit.framework
    • ImageIO.framework
    • libc++.tbd
    • libz.tbd
    • OpenGLES.framework
    • QuartzCore.framework
    • SystemConfiguration.framework
    • UIKit.framework
  9. Choose your project, rather than a specific target, and open the Build Settings tab. In the Other Linker Flags section, add -ObjC. If these settings are not visible, change the filter in the Build Settings bar from Basic to All.

  10. To install the Places SDK for iOS, see Get Started with the Places SDK for iOS.

Get an API key

To authenticate your app to the Maps SDK for iOS, you need an API key restricted to an app-specific bundle identifier. This combination creates an iOS-restricted API key.

Click the button below, which guides you through the process of obtaining an API key. If your project already has an API key with iOS restriction, you may use that key. Important: In the project drop-down menu, you must select the project created for you when you purchased the Google Maps APIs Premium Plan. The project name starts with Google Maps APIs for Business or Google Maps for Work or Google Maps.

Get Started

Alternatively, follow these steps to get an API key:

  1. Go to the Google Cloud Platform Console.
  2. From the Project drop-down menu, select the Google Maps Premium project.*
  3. Click Continue.
  4. On the Credentials page, get an API key.
    Note: If you have a key with iOS restrictions, you may use that key. You can use the same key with any of your iOS applications within the same project.
  5. From the dialog displaying the API key, select Restrict key to set an iOS restriction on the API key.
  6. In the Restrictions section, select iOS apps, then enter your app's bundle identifier. For example: com.example.hellomap.
  7. Click Save.

    Your new iOS-restricted API key appears in the list of API keys for your project. An API key is a string of characters, something like this:

    AIzaSyBdVl-cTICSwYKrZ95SuvNw7dbMuDt1KG0

You can also look up an existing key in the Google Cloud Platform Console.

For more information on using the Google Cloud Platform Console, see Google Cloud Platform Console Help.

Add the API key to your app

Swift

Add your API key to your AppDelegate.swift as follows:

  1. Add the following import statement:
    import GoogleMaps
  2. Add the following to your application(_:didFinishLaunchingWithOptions:) method, replacing YOUR_API_KEY with your API key:
    GMSServices.provideAPIKey("YOUR_API_KEY")
  3. If you are also using the Places API, add your key again as shown here:
    GMSPlacesClient.provideAPIKey("YOUR_API_KEY")

Objective-C

Add your API key to your AppDelegate.m as follows:

  1. Add the following import statement:
    @import GoogleMaps;
  2. Add the following to your application:didFinishLaunchingWithOptions: method, replacing YOUR_API_KEY with your API key:
    [GMSServices provideAPIKey:@"YOUR_API_KEY"];
  3. If you are also using the Places API, add your key again as shown here:
    [GMSPlacesClient provideAPIKey:@"YOUR_API_KEY"];

Add a map

The code below demonstrates how to add a simple map to an existing ViewController. If you're creating a new app, first follow the installation instructions above, and create a new Single View Application; disabling Use Storyboards but enabling Use Automatic Reference Counting (ARC).

Now, add or update a few methods inside your app's default ViewController to create and initialize an instance of GMSMapView.

Swift

import UIKit
import GoogleMaps

class YourViewController: UIViewController {

  // You don't need to modify the default init(nibName:bundle:) method.

  override func loadView() {
    // Create a GMSCameraPosition that tells the map to display the
    // coordinate -33.86,151.20 at zoom level 6.
    let camera = GMSCameraPosition.camera(withLatitude: -33.86, longitude: 151.20, zoom: 6.0)
    let mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)
    view = mapView

    // Creates a marker in the center of the map.
    let marker = GMSMarker()
    marker.position = CLLocationCoordinate2D(latitude: -33.86, longitude: 151.20)
    marker.title = "Sydney"
    marker.snippet = "Australia"
    marker.map = mapView
  }
}

Objective-C

#import "YourViewController.h"
#import <GoogleMaps/GoogleMaps.h>

@implementation YourViewController

// You don't need to modify the default initWithNibName:bundle: method.

- (void)loadView {
  // Create a GMSCameraPosition that tells the map to display the
  // coordinate -33.86,151.20 at zoom level 6.
  GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:-33.86
                                                          longitude:151.20
                                                               zoom:6];
  GMSMapView *mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];
  mapView.myLocationEnabled = YES;
  self.view = mapView;

  // Creates a marker in the center of the map.
  GMSMarker *marker = [[GMSMarker alloc] init];
  marker.position = CLLocationCoordinate2DMake(-33.86, 151.20);
  marker.title = @"Sydney";
  marker.snippet = @"Australia";
  marker.map = mapView;
}

@end

Run your application. You should see a map with a single marker centered over Sydney, Australia. If you see the marker, but the map is not visible, confirm that you have provided your API key.

More information

Attribution requirements

You must include the attribution text as part of a legal notices section in your application. Google recommends including legal notices as an independent menu item, or as part of an "About" menu item.

You can get the attribution text by making a call to GMSServices.openSourceLicenseInfo().

Supported platforms

Developing an iOS application with the Maps SDK for iOS distributed with the Premium Plan requires the following:

  • Xcode 9.0 or later.
  • iOS SDK 11.0 or later.

Applications developed with this SDK will work on iOS 8.0 and later.

Comparing versions

The following table describes the key differences between the using standard Maps SDK for iOS and using the SDK with the Premium Plan.

  Standard Maps SDK for iOS Premium Plan
Support Channels Community based support. Access to Premium support.
Terms Subject to the Google Maps Platform Terms of Service. Subject to Google Maps APIs Premium Plan terms of use.

Documentation

The main source of information about the Maps SDK for iOS is the developer and reference documentation available elsewhere on our site.