Navigation SDK is currently available only to select customers. Contact sales to learn more.

Set up your project

Stay organized with collections Save and categorize content based on your preferences.

Follow this guide to integrate the Navigation SDK for iOS into an iOS app.

Prerequisites

  • Before you start using the Navigation SDK for iOS, you need a project with a billing account and the Maps SDK for iOS enabled. We recommend creating multiple project owners and billing administrators, so that you'll always have someone with these roles available to your team. To learn more, see Set up in Cloud Console.
  • To build a project using the Navigation SDK for iOS, you need version 13.0 or later of Xcode.
  • The minimum target iOS version for the navigation SDK is 13.0.

Installing the SDK

Install manually

Follow these steps to install the frameworks for the Navigation SDK for iOS, and the Maps SDK for iOS:

  1. Unpack the source files that you received from Google.
  2. Launch Xcode and either open an existing project, or create a new project. If you're new to iOS, create a new project and select the iOS App template.
  3. Remove all existing Maps and Places references from the project.
  4. Drag the following bundles into your project under Frameworks, Libraries, and Embedded Content to install both the Maps and Navigation SDKs (when prompted, select Copy items if needed):
    • GoogleMapsBase.framework
    • GoogleMaps.framework
    • GoogleMapsCore.framework
    • GoogleNavigation.framework
  5. Right-click GoogleMaps.framework in your project, and select Show In Finder
  6. Drag the GoogleMaps.bundle from the Resources folder into the top level directory of your Xcode project. When prompted, ensure Copy items into destination group's folder is not selected.
  7. Repeat the previous two steps to add GoogleNavigation.bundle.
  8. Select your project from the Project Navigator, and choose your application's target.
  9. Open the Build Phases tab, and within Link Binary with Libraries, add the following frameworks and libraries:
    • Accelerate.framework
    • AudioToolbox.framework
    • AVFoundation.framework
    • CoreData.framework
    • CoreGraphics.framework
    • CoreLocation.framework
    • CoreTelephony.framework
    • CoreText.framework
    • GLKit.framework
    • ImageIO.framework
    • libc++.tbd
    • libxml2.tbd
    • libz.tbd
    • OpenGLES.framework
    • QuartzCore.framework
    • SystemConfiguration.framework
    • UIKit.framework
    • WebKit.framework
  10. In your application's target, select the Capabilities tab, turn on Background Modes, and enable the following modes:
    • Audio, AirPlay, and Picture in Picture
    • Location updates
  11. Choose your project, rather than a specific target, and open the Build Settings tab. In the Other Linker Flags section, add ‑ObjC for both debug and release. If these settings are not visible, change the filter in the Build Settings bar from Basic to All.
  12. Open Info.plist and add the following key-value pairs:
    • Key: NSLocationWhenInUseUsageDescription (Privacy - Location When In Use Usage Description)
      Value: "This app needs permission to use your location for turn-by-turn navigation."
    • Key: NSLocationAlwaysAndWhenInUseUsageDescription (Privacy - Location Always and When In Use Usage Description)
      Value: "This app needs permission to use your location for turn-by-turn navigation."

Install the XCFramework

An XCFramework is a binary package that you can use on multiple platforms, including machines using the M1 chipset, to install the Maps SDK for iOS, and the Navigation SDK for iOS. This guide shows how to manually add the XCFramework containing the Maps SDK for iOS to your project and configure your build settings in Xcode.

Follow these steps to install the frameworks for the Maps SDK for iOS, and the Navigation SDK for iOS:

  1. Unpack the source files that you received from Google.
  2. Launch Xcode and either open an existing project, or create a new project. If you're new to iOS, create a new project and select the iOS App template.
  3. Remove all existing Maps and Places references from the project.
  4. Drag the following XCFramework into your project under Frameworks, Libraries, and Embedded Content to install both the Maps and Navigation SDKs (when prompted, select Copy items if needed):
    • GoogleMapsBase.xcframework
    • GoogleMaps.xcframework
    • GoogleMapsCore.xcframework
    • GoogleNavigation.xcframework
  5. Right-click GoogleMaps.xcframework in your project, and select Show In Finder
  6. Drag the GoogleMaps.bundle from the ios-arm64/GoogleMaps.framework/Resources folder into the top level directory of your Xcode project. When prompted, ensure Copy items into destination group's folder is not selected.
  7. Repeat the previous two steps to add GoogleNavigation.bundle.
  8. Select your project from the Project Navigator, and choose your application's target.
  9. Open the Build Phases tab, and within Link Binary with Libraries, add the following frameworks and libraries:
    • Accelerate.framework
    • AudioToolbox.framework
    • AVFoundation.framework
    • CoreData.framework
    • CoreGraphics.framework
    • CoreLocation.framework
    • CoreTelephony.framework
    • CoreText.framework
    • GLKit.framework
    • ImageIO.framework
    • libc++.tbd
    • libxml2.tbd
    • libz.tbd
    • OpenGLES.framework
    • QuartzCore.framework
    • SystemConfiguration.framework
    • UIKit.framework
    • WebKit.framework
  10. In your application's target, select the Capabilities tab, turn on Background Modes, and enable the following modes:
    • Audio, AirPlay, and Picture in Picture
    • Location updates
  11. Choose your project, rather than a specific target, and open the Build Settings tab. In the Other Linker Flags section, add ‑ObjC for both debug and release. If these settings are not visible, change the filter in the Build Settings bar from Basic to All.
  12. Open Info.plist and add the following key-value pairs:
    • Key: NSLocationWhenInUseUsageDescription (Privacy - Location When In Use Usage Description)
      Value: "This app needs permission to use your location for turn-by-turn navigation."
    • Key: NSLocationAlwaysAndWhenInUseUsageDescription (Privacy - Location Always and When In Use Usage Description)
      Value: "This app needs permission to use your location for turn-by-turn navigation."

Adding an API key to your project

The following examples show how to add the API key to your project in Xcode:

Swift

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

  1. Add the following import statements:
    import GoogleMaps
    import GoogleNavigation
  2. Add the following to your application(_:didFinishLaunchingWithOptions:) method:
    GMSServices.provideAPIKey("YOUR_API_KEY")

Objective-C

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

  1. Add the following import statements:
    @import GoogleMaps;
    @import GoogleNavigation;
  2. Add the following to your application:didFinishLaunchingWithOptions: method:
    [GMSServices provideAPIKey:@"YOUR_API_KEY"];

Adding a map

This code demonstrates how to add a simple map to an existing ViewController, including some initial settings for navigation.

Before navigation can be enabled, the user must agree to the terms and conditions. To prompt the user, call GMSNavigationServices.showTermsAndConditionsDialogIfNeeded(), then check to see whether the terms have been accepted. If the user rejects the terms, mapView.isNavigationEnabled = true has no effect, and mapView.navigator is nil.

Swift

import UIKit
import GoogleNavigation

class ViewController: UIViewController {

  var mapView: GMSMapView!
  var locationManager: CLLocationManager!

  override func loadView() {
    locationManager = CLLocationManager()
    locationManager.requestAlwaysAuthorization()

    let camera = GMSCameraPosition.camera(withLatitude: 47.67, longitude: -122.20, zoom: 14)
    mapView = GMSMapView.map(withFrame: CGRect.zero, camera: camera)

    // Show the terms and conditions.
    let companyName = "Ride Sharing Co."
    GMSNavigationServices.showTermsAndConditionsDialogIfNeeded(
      withCompanyName: companyName) { termsAccepted in
      if termsAccepted {
        // Enable navigation if the user accepts the terms.
        self.mapView.isNavigationEnabled = true
      } else {
        // Handle the case when the user rejects the terms and conditions.
      }
    }

    view = mapView
  }

  // TODO: Add navigation code.

}

Objective-C

#import "ViewController.h"
@import GoogleNavigation;

@interface ViewController ()
@end

@implementation ViewController
GMSMapView *_mapView;
CLLocationManager *_locationManager;

- (void)loadView {

  _locationManager = [[CLLocationManager alloc] init];
  [_locationManager requestAlwaysAuthorization];

  GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:47.67
                                                          longitude:-122.20
                                                               zoom:14];
  _mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];

  // Show the terms and conditions.
  NSString *companyName = @"Ride Sharing Co.";
  [GMSNavigationServices
    showTermsAndConditionsDialogIfNeededWithCompanyName:companyName
    callback:^(BOOL termsAccepted) {
     if (termsAccepted) {
       // Enable navigation if the user accepts the terms.
       _mapView.navigationEnabled = YES;
     } else {
       // Handle the case when the user rejects the terms and conditions.
     }
   }];

  self.view = _mapView;
}

// TODO: Add navigation code.

@end

Run your application. You should see a map centered over Kirkland, Washington. If the map is not visible, confirm that you have provided the correct API key.