The Mapbox Navigation SDK is comprised of two modules:
- MapboxCoreNavigation - responsible for rerouting, snapping, progress updates etc.
- MapboxNavigation - responsible for everything UI related.
If the UI provided by MapboxNavigation is not something that can work for your project, it is possible to create a custom navigation experience built on top of MapboxCoreNavigation directly. Note, this is not ideal as it will be a lot of work for the developer. If there is something missing from the UI or not optimal, feel free to open a ticket instead of venturing down this path.
The installation process is very similar to installing the MapboxNavigation framework:
To install the MapboxCoreNavigation framework in an application using Swift Package Manager:
-
Go to your Mapbox account dashboard and create an access token that has the
DOWNLOADS:READ
scope. PLEASE NOTE: This is not the same as your production Mapbox API token. Make sure to keep it private and do not insert it into any Info.plist file. Create a file named.netrc
in your home directory if it doesn’t already exist, then add the following lines to the end of the file:machine api.mapbox.com login mapbox password PRIVATE_MAPBOX_API_TOKEN
where PRIVATE_MAPBOX_API_TOKEN is your Mapbox API token with the
DOWNLOADS:READ
scope. -
In Xcode, go to File ‣ Swift Packages ‣ Add Package Dependency.
-
Enter
https://github.com/mapbox/mapbox-navigation-ios.git
as the package repository and click Next. -
Set Rules to Version, Up to Next Major, and enter
2.1.0
as the minimum version requirement. Click Next.
To install the MapboxCoreNavigation framework in another package rather than an application, run swift package init
to create a Package.swift, then add the following dependency:
// Latest stable release
.package(name: "MapboxCoreNavigation", url: "https://github.com/mapbox/mapbox-navigation-ios.git", from: "2.1.0")
// Latest prerelease
.package(name: "MapboxCoreNavigation", url: "https://github.com/mapbox/mapbox-navigation-ios.git", .exact("2.1.0-rc.2"))
To install Mapbox Core Navigation using CocoaPods:
-
Go to your Mapbox account dashboard and create an access token that has the
DOWNLOADS:READ
scope. PLEASE NOTE: This is not the same as your production Mapbox API token. Make sure to keep it private and do not insert it into any Info.plist file. Create a file named.netrc
in your home directory if it doesn’t already exist, then add the following lines to the end of the file:machine api.mapbox.com login mapbox password PRIVATE_MAPBOX_API_TOKEN
where PRIVATE_MAPBOX_API_TOKEN is your Mapbox API token with the
DOWNLOADS:READ
scope. -
Create a Podfile with the following specification:
# Latest stable release pod 'MapboxCoreNavigation', '~> 2.1' # Latest prerelease pod 'MapboxCoreNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :tag => 'v2.1.0-rc.2'
-
Run
pod repo update && pod install
and open the resulting Xcode workspace.
To install Mapbox Navigation using Carthage v0.38 or above:
-
Go to your Mapbox account dashboard and create an access token that has the
DOWNLOADS:READ
scope. PLEASE NOTE: This is not the same as your production Mapbox API token. Make sure to keep it private and do not insert it into any Info.plist file. Create a file named.netrc
in your home directory if it doesn’t already exist, then add the following lines to the end of the file:machine api.mapbox.com login mapbox password PRIVATE_MAPBOX_API_TOKEN
where PRIVATE_MAPBOX_API_TOKEN is your Mapbox API token with the
DOWNLOADS:READ
scope. -
(Optional) Clear your Carthage caches:
rm -rf ~/Library/Caches/carthage/ ~/Library/Caches/org.carthage.CarthageKit/binaries/{MapboxCommon-ios,MapboxNavigationNative}
-
Create a Cartfile with the following dependency:
# Latest stable release github "mapbox/mapbox-navigation-ios" ~> 2.1 # Latest prerelease github "mapbox/mapbox-navigation-ios" "v2.1.0-rc.2"
-
Run
carthage bootstrap --platform iOS --use-xcframeworks --cache-builds --use-netrc
. -
Follow the rest of Carthage’s iOS integration instructions. Your application target’s Embed Frameworks build phase should include
MapboxCoreNavigation.xcframework
,MapboxNavigationNative.xcframework
,MapboxCommon.xcframework
, andMapboxAccounts.xcframework
.
To install the MapboxCoreNavigation framework using Swift Package Manager within Xcode:
-
Go to your Mapbox account dashboard and create an access token that has the
DOWNLOADS:READ
scope. PLEASE NOTE: This is not the same as your production Mapbox API token. Make sure to keep it private and do not insert it into any Info.plist file. Create a file named.netrc
in your home directory if it doesn’t already exist, then add the following lines to the end of the file:machine api.mapbox.com login mapbox password PRIVATE_MAPBOX_API_TOKEN
where PRIVATE_MAPBOX_API_TOKEN is your Mapbox API token with the
DOWNLOADS:READ
scope. -
In Xcode, go to File ‣ Swift Packages ‣ Add Package Dependency.
-
Enter
https://github.com/mapbox/mapbox-navigation-ios.git
as the package repository and click Next. -
Set Rules to Version, Up to Next Major, and enter
2.1.0
as the minimum version requirement. Click Next.