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.
If you are using the Google Maps SDK for iOS with a Google Maps APIs Premium Plan license, see the Premium Plan getting-started guide instead.
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:
- 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.)
- Create a file named
Podfilein your project directory. This file defines your project's dependencies. -
Edit the
Podfileand add your dependencies. Here is an example which includes the dependency you need for the Google Maps SDK for iOS:source 'https://github.com/CocoaPods/Specs.git' pod 'GoogleMaps'
-
Save the
Podfile. -
Open a terminal and go to the directory containing the
Podfile:$ cd <path-to-project>
-
Run the
pod installcommand. This will install the APIs specified in thePodfile, along with any dependencies they may have.$ pod install
-
Close Xcode, and then open (double-click) your project's
.xcworkspacefile to launch Xcode. From this time onwards, you must use the.xcworkspacefile to open the project.
Step 4: Get an API key
Follow these steps to enable the necessary APIs on the Google Developers Console. You must enable the Google Maps SDK for iOS, and optionally the Google Places API for iOS. If your project doesn't already have an iOS key (a type of API key), these instructions also help you create a new API key.
- Go to the Google Developers Console.
- Create or select a project.
- Click Continue to enable the Google Maps SDK for iOS API.
Optionally, you can also enable the Google Places API for iOS now. Alternatively, you can enable the Google Places API for iOS later, if you need it. - On the Credentials page, get an iOS key and set the API
credentials.
Note: If you have an existing iOS key, you may use that key. You can use the same key with any of your iOS applications within the same project. - Enter your app's bundle identifier when prompted. For example:
com.example.hellomap. Click Create.
Your new iOS 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 Developers Console.
For more information, see Developers Console Help.
Step 5: Add the API key to your application
Objective-C
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 YOUR_API_KEY with your API key:[GMSServices provideAPIKey:@"YOUR_API_KEY"];
Swift
Add your API key to your AppDelegate.swift as follows:
- Add the following import statement:
import GoogleMaps
- Add the following to your
application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?)func, replacing YOUR_API_KEY with your API key:GMSServices.provideAPIKey("YOUR_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
import GoogleMaps
class YourViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let camera = GMSCameraPosition.cameraWithLatitude(-33.86,
longitude: 151.20, zoom: 6)
let mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
mapView.myLocationEnabled = true
self.view = mapView
let 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.
Step 7: Declare the URL schemes used by the API
With iOS 9 and Xcode 7, apps must declare the URL schemes that they intend to
open, by specifying the schemes in the app's Info.plist file. The
Google Maps SDK for iOS opens the Google Maps mobile app when the user
clicks the Google logo on the map, and your app therefore needs to declare the
relevant URL schemes.
To declare the URL schemes used by the Google Maps SDK for iOS, add the
following lines to your Info.plist:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>googlechromes</string>
<string>comgooglemaps</string>
</array>
The following screenshot shows the configuration in the Xcode user interface:

Without the above declaration, the following errors occur when the user taps the Google logo on the map:
-canOpenURL: failed for URL: "comgooglemaps://" - error: "This app is not allowed to query for scheme comgooglemaps"
-canOpenURL: failed for URL: "googlechromes://" - error: "This app is not allowed to query for scheme googlechromes"
To eliminate these errors, add the declaration to your Info.plist as described above.
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:
- Remove all references to the previous framework from your Xcode project.
- Follow the instructions above to install the Google Maps SDK for iOS using CocoaPods.
- Make any necessary changes as a result of the upgrade. See the release notes for a list of the changes in each release.
- 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:
- Change your pod name to
GoogleMaps. - Run
pod install. - Make any necessary changes as a result of the upgrade. See the release notes for a list of the changes in each release.
- 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:
- Check your
Podfilefor 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. - Run
pod update. - Make any necessary changes as a result of the upgrade. See the release notes for a list of the changes in each release.
- Clean and rebuild your project by selecting Product > Clean and then Product > Build.
