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 7.3 or later of Xcode.
Step 2: Install the SDK
Use 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 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 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 dependencies you need for the Google Maps SDK for iOS and Places API 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'. - 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.
Install manually
This guide shows how to manually add the GoogleMaps framework to your project and configure your build settings in Xcode.
- Download the SDK source files: GoogleMaps-2.1.1.
- Unpack the source files.
- 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.
- Drag the following bundles into your project (when prompted, select
Copy items if needed):
Subspecs/Base/Frameworks/GoogleMapsBase.frameworkSubspecs/Maps/Frameworks/GoogleMaps.frameworkSubspecs/Maps/Frameworks/GoogleMapsCore.framework
Premium Plan customers must also include
Subspecs/M4B/Frameworks/GoogleMapsM4B.framework. - Right-click
GoogleMaps.frameworkin your project, and select Show In Finder. - Drag the
GoogleMaps.bundlefrom theResourcesfolder into your project. When prompted, ensure Copy items into destination group's folder is not selected. - Select your project from the Project Navigator, and choose your application's target.
- Open the Build Phases tab, and within Link Binary with
Libraries, add the following frameworks:
GoogleMapsBase.frameworkGoogleMaps.frameworkGoogleMapsCore.frameworkGoogleMapsM4B.framework(Premium Plan customers only)Accelerate.frameworkCoreData.frameworkCoreGraphics.frameworkCoreLocation.frameworkCoreText.frameworkGLKit.frameworkImageIO.frameworklibc++.tbdlibz.tbdOpenGLES.frameworkQuartzCore.frameworkSystemConfiguration.frameworkUIKit.framework
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.To install the Places API for iOS, see Get Started with the Places API for iOS.
Step 4: Get an API key
Click the button below, which guides you through the process of enabling the Google Maps SDK for iOS and obtaining an API key. If your project already has an iOS-restricted API key, you may use that key.
Get a KeyAlternatively, follow these steps to get an API key:
- Go to the Google API Console.
- Create or select a project.
- Click Continue to enable the Google Maps SDK for iOS.
- 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. - From the dialog displaying the API key, select Restrict key to set an iOS restriction on the API key.
- In the Restrictions section, select iOS apps, then
enter your app's bundle identifier. For example:
com.example.hellomap. - 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 API Console.
For more information on using the Google API Console, see API Console Help.
Step 5: Add the API key to your application
Swift
Add your API key to your AppDelegate.swift 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") - 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:
- 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"];
- If you are also using the Places API, add your key again as shown here:
[GMSPlacesClient 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, 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.
Step 7: Declare the URL schemes used by the API
Beginning 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 in the note 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.
