Maps SDK for iOS

Current version: v6.2.1 View changelog

  • Custom map styles
  • Offline maps
  • Fast vector maps
  • Compatible with other Mapbox tools

The Mapbox Maps SDK for iOS is a library for embedding highly customized maps within iOS applications. Features include:

  • Custom styling: Use one of our beautiful template styles or your own custom style built with Mapbox Studio. You can even alter your map's style at runtime.
  • Offline maps: Do more without a data connection by storing your maps offline.
  • Data visualizations: Include your own custom data to create powerful interactive data visualizations.
  • Open source: Contribute and keep track of new features in our open-source GitHub repository.

The Mapbox Maps SDK for iOS is compatible with applications built in Xcode 8 or above and deployed on iOS 9 and above.

Upgrade to the most recent version

For information about migrating from older versions of the Mapbox Maps SDK for iOS to newer ones, see:

  • v4.x.x to v5.x.x: This version change improved the method for counting monthly active users. No migration guide is required, but you can read more about these changes in the changelog and the Pricing by products guide.
  • v3.7.x to v4.0.x

Install the Maps SDK

Before starting to develop your application with the Maps SDK, you'll need to configure your credentials and add the SDK as a dependency.

Configure credentials


If you plan to install the SDK via direct download, you do not need to configure a secret token. You will still need to configure a public token.

Before installing the SDK, you will need to gather the appropriate credentials. The SDK requires two pieces of sensitive information from your Mapbox account. If you don't have a Mapbox account: sign up and navigate to your Account page. You'll need:

  • A public access token: From your account's tokens page, you can either copy your default public token or click the Create a token button to create a new public token.
  • A secret access token with the Downloads:Read scope.
    1. From your account's tokens page, click the Create a token button.
    2. From the token creation page, give your token a name and make sure the box next to the Downloads:Read scope is checked.
    3. Click the Create token button at the bottom of the page to create your token.
    4. The token you've created is a secret token, which means you will only have one opportunity to copy it somewhere secure.

You should not expose these access tokens in publicly-accessible source code where unauthorized users might find them. Instead, you should store them somewhere safe on your computer and make sure they're only added when your app is compiled. Once this configuration step has been completed, you will be able to reference your credentials in other parts of your app.

Configure your secret token

Your secret token enables you to download the SDK directly from Mapbox. In order to use your secret token, you will need to store it a .netrc file in your home directory. This approach helps avoid accidentally exposing your secret token by keeping it out of your application's source code. Depending on your environment, you may have this file already, so check first before creating a new one.

The .netrc file is a plain text file that is used in certain development environments to store credentials used to access remote servers. To set up the credentials required to download the SDK, add the following entry to your .netrc file:

login mapbox

Configure your public token

To configure your public access token, open your project's Info.plist file and add a MGLMapboxAccessToken key whose value is your public access token.

If you ever need to rotate your access token, you will need to update the token value in your Info.plist file accordingly.

Access token best practices

Learn how to keep access tokens private in mobile apps.

Configure location permissions

The Mapbox Maps SDK for iOS requests permissions for user location on your behalf when MGLMapView.showsUserLocation is set to YES.

Prior to iOS 14, the device could only send the user’s exact location. With iOS 14, users can opt into Approximate Location. Since users may toggle precise location off when initial permission for their location is requested by the app or in the System settings, developers are strongly encouraged to support Approximate Location.

Handle the User Interface

The Maps SDK provides an approximate user location indicator that mirrors the approximate user location indicator previewed by Apple. This indicator will appear by default when MGLMapView.showsUserLocation is set to YES and precise location has been opted out. You may further configure or hide this component.

Request temporary access to precise location

Certain application features may require precise location. The Mapbox Maps SDK for iOS provides a wrapper of Apple’s CoreLocation APIs that requests temporary access to precise location when the user has opted out at the application settings level:


Make the following adjustments to your Info.plist file to provide explanations for system prompts that may appear during location prompts:

Provide users a brief explanation of how the app will use their location data for temporary access:

<string>Your precise location is used to calculate turn-by-turn directions, show your location on the map, and help improve the map.</string>

Add MGLAccuracyAuthorizationDescription as an element of the NSLocationTemporaryUsageDescriptionDictionary dictionary to give users a brief explanation of why a feature in your app requires their exact location:

    <string>Please enable precise location. Turn-by-turn directions only work when precise location data is available.</string>

As a convenience, if your application uses a MGLMapView.userTrackingMode to track user location, the Maps SDK will check for full accuracy authorization and request access on your behalf.

Handle changes in location authorization

At any point, a user may grant or revoke access to precise location in System settings. The Maps SDK for iOS provides a delegate method to handle these changes:

[MGLMapViewDelegate mapView:didChangeLocationManagerAuthorization:]

For more detail, see the example implementation of this delegate method.

After the current session elapses, your users will be prompted to give location permissions the next time they open your app. Your users must enable precise location during this prompt or in the app’s System settings to avoid being asked repeatedly for location accuracy permissions.

Add the dependency

Mapbox provides the Maps SDK via Carthage, CocoaPods , and direct download. You can choose whichever you prefer.

To add the Mapbox Maps SDK dependency with CocoaPods, you will need to configure your build to download the Maps SDK from Mapbox directly. This requires a valid username and an access token with the Downloads: Read scope. In a previous step, you added these items to your .netrc file.

  1. Add the following to your Podfile:

    target 'TargetNameForYourApp' do
      pod 'Mapbox-iOS-SDK', '~> 6.2.1'
  2. Run pod install to install the dependency.

Add a map

You can add a map to your application in one of three ways: using Swift, Objective-C, or a storyboard. Select one of the following options to learn how to create a map using your preferred method.

Insert the following code snippets into your ViewController.

import Mapbox
class ViewController: UIViewController {
override func viewDidLoad() {
let url = URL(string: "mapbox://styles/mapbox/streets-v11")
let mapView = MGLMapView(frame: view.bounds, styleURL: url)
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
mapView.setCenter(CLLocationCoordinate2D(latitude: 59.31, longitude: 18.06), zoomLevel: 9, animated: false)

Run your application and you will see a map on the screen.

Running into problems installing? Read more about common installation issues in our troubleshooting guide.

Integration with other tools

The Mapbox Maps SDK for iOS works with other Mapbox products. Mix and match other tools and plugins to create a location-savvy application to your exact specifications. Learn more about how to use Mapbox Studio as an iOS developer.

Mapbox Studio

The Mapbox Maps SDK is compatible with Mapbox Studio. Design a map that seamlessly matches your brand and application design, then infuse it with your own custom data all within the Mapbox Studio web interface.

Directions and turn-by-turn navigation

Embed real-time, turn-by-turn navigation right inside your application. The Mapbox Navigation SDK for iOS provides a high-quality user experience out of the box, so you don’t have to send your users to another application. Many customization options and reusable components allow you to adapt the interface to your unique use case and design.

The Navigation SDK features traffic-aware directions for driving, cycling, or walking between multiple locations, powered by the Mapbox Directions API. MapboxDirections.swift is also available for applications that need direct access to directions without turn-by-turn functionality.

Turn coordinates into addresses or addresses into coordinates with MapboxGeocoder.swift, powered by the Mapbox Geocoding API.

Static maps

The Mapbox Maps SDK for iOS includes methods to generate a static snapshot of an existing map within your application. Use the MGLMapSnapshotter class to create a static raster image of a map, without having to make a request to another API.

Deliver a consistent experience across your companion tvOS and watchOS applications with static map snapshots using MapboxStatic.swift, powered by the Mapbox Static API.


Pricing with the Mapbox Maps SDK for iOS is measured using monthly active users. See our pricing page for more details.

Available resources

Documentation for the Mapbox Maps SDK for iOS comes in the form of:

If you can't find what you're looking for, reach out to our support team.

Was this page helpful?