Hide

Getting Started

Before you can begin working with Google Maps on iOS, you need to download the Google Maps SDK for iOS and ensure that you have an API key.

Complete release notes are available for each release.

Step 1: Get the latest version of Xcode

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

Step 2: Get CocoaPods

The Google 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 OS X by running the following command from the terminal. For details, see the CocoaPods Getting Started guide.

$ sudo gem install cocoapods

Step 3: Install the API using CocoaPods

Create a Podfile for the Google 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, and ensure that Use Automatic Reference Counting is turned on.)
  2. Create a file named Podfile in your project directory. This file defines your project's dependencies, and is commonly referred to as a Podspec.
  3. Edit the Podfile and add your dependencies. Here is a simple Podspec, including the name of the pod you need for the Google Maps SDK for iOS:

    source 'https://github.com/CocoaPods/Specs.git'
    platform :ios, '8.1'
    pod 'GoogleMaps'

  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 Podspec, 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.

Step 4: Enable the required APIs on the Google Developers Console

You need to activate the Google Maps SDK for iOS, and optionally the Google Places API for iOS, in your project on the Google Developers Console.

If you want to be guided through the process and activate both the APIs automatically, click this link.

Alternatively, you can activate the APIs yourself in the Developers Console, by doing the following:

  1. Go to the Google Developers Console.
  2. Select a project, or create a new one.
  3. Enable the Google Maps SDK for iOS, and optionally the Google Places API for iOS: In the sidebar on the left, expand APIs & auth. Next, click APIs. Select the Enabled APIs link in the API section to see a list of all your enabled APIs. Make sure that the API is on the list of enabled APIs. If you have not enabled it, select the API from the list of APIs, then select the Enable API button for the API.

Step 5: Get an iOS API key

Using an API key enables you to monitor your application's API usage, and ensures that Google can contact you about your application if necessary. The key is free, you can use it with any of your applications that call the Google Maps SDK for iOS, and it supports an unlimited number of users. You obtain an API key from the Google Developers Console by providing your application's bundle identifier.

If your project doesn't already have a key for iOS applications, follow these steps to create an API key from the Google Developers Console:

  1. In the sidebar on the left, select Credentials.
  2. Click Create New Key and then select iOS key.
  3. In the resulting dialog, enter your app's bundle identifier. For example: com.example.hellomap.
  4. Click Create.

    The Google Developers Console displays a section titled Key for iOS applications with a character-string API key. Here's an example:

    AIzaSyBdVl-cTICSwYKrZ95SuvNw7dbMuDt1KG0

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

    • Add the following import statement:
      @import GoogleMaps;
    • Add the following to your application:didFinishLaunchingWithOptions: method, replacing API_KEY with your API key:
      [GMSServices provideAPIKey:@"API_KEY"];

Step 6: Add a map

The code below demonstrates how to add a simple map to an existing ViewController. If you're creating a new app to iOS, first follow the installation instructions above, and create a new Single View Application.

Add or update a few methods inside your app's default ViewController to create and initialize an instance of GMSMapView, as shown in the sample below.

Objective-C

#import "YourViewController.h"
@import GoogleMaps;

@implementation YourViewController {
  GMSMapView *mapView_;
}

- (void)viewDidLoad {
  // 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];
  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

Swift

import UIKit

class YourViewController: UIViewController {

  override func viewDidLoad() {
    super.viewDidLoad()

    var camera = GMSCameraPosition.cameraWithLatitude(-33.86,
        longitude: 151.20, zoom: 6)
    var mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
    mapView.myLocationEnabled = true
    self.view = mapView

    var marker = GMSMarker()
    marker.position = CLLocationCoordinate2DMake(-33.86, 151.20)
    marker.title = "Sydney"
    marker.snippet = "Australia"
    marker.map = mapView
  }
}

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.

Experiment with the Google Maps SDK demo project

Try the SDK demos using pod try GoogleMaps. For more details, see the guide to code samples.

Upgrade from an earlier version

Follow these instructions to upgrade an existing project to the most recent version of the Google Maps SDK for iOS.

If you previously installed the Google Maps SDK for iOS from a zip file containing a static framework:

  1. Remove all references to the previous framework from your Xcode project.
  2. Follow the instructions above to install the Google Maps SDK for iOS using CocoaPods.
  3. Make any necessary changes as a result of the upgrade. See the release notes for a list of the changes in each release.
  4. Clean and rebuild your project by selecting Product > Clean and then Product > Build.

If you previously installed the Google Maps SDK for iOS from the Google-Maps-iOS-SDK pod:

  1. Change your pod name to GoogleMaps.
  2. Run pod install.
  3. Make any necessary changes as a result of the upgrade. See the release notes for a list of the changes in each release.
  4. Clean and rebuild your project by selecting Product > Clean and then Product > Build.

If you previously installed the Google Maps SDK for iOS from the GoogleMaps pod:

  1. Check your Podfile for any version limiter, and ensure you remove or update the version to ensure you get the version you need. See the release notes for a list of version numbers.
  2. Run pod update.
  3. Make any necessary changes as a result of the upgrade. See the release notes for a list of the changes in each release.
  4. Clean and rebuild your project by selecting Product > Clean and then Product > Build.

Send feedback about...

Google Maps SDK for iOS