Migrate to v2
Mapbox Navigation SDK for iOS v2 is a major new version of the SDK. To upgrade, follow the installation instructions. Note that the MapboxNavigation framework’s Carthage support has been discontinued in favor of Swift Package Manager. If you decide to keep using Carthage for the MapboxCoreNavigation framework, you will need to migrate from framework bundles to XCFrameworks.
Starting with v2.0.0, you can choose from two new pricing options depending on your use case: metered or unlimited trips. Also, the Mapbox Navigation SDK is licensed under the Mapbox Terms of Service, a proprietary license. It is no longer available under the permissive ISC License.
Navigation SDK v2 includes many important changes to the public APIs of the MapboxNavigation and MapboxCoreNavigation frameworks as well as their dependencies. There are several backwards-incompatible changes to be aware of as you upgrade, which are discussed below and divided by framework so that you can upgrade different portions of your application at different times.
System requirements
- Supported dependency managers:
- Swift Package Manager (new)
- CocoaPods
- Carthage (
MapboxCoreNavigationonly.MapboxNavigationandmapbox-directions-swiftcommand line tool no longer supported.)
- Minimum Xcode version required to build the SDK: 12.4 (11.x no longer supported)
- Minimum iOS deployment target: 11.0 (10.x no longer supported)
Upgrading Turf from v1.x to v2.0.0
Turf v2 revamps the GeoJSON types to better conform to the GeoJSON specification. Consult the Turf v2.0.0 release notes, which detail changes to the type system and examples for upgrading.
GeoJSON is now represented using Turf types throughout Mapbox’s SDKs, including in the Maps SDK’s public API, so it is no longer necessary to convert between Turf GeoJSON types and the Maps SDK’s shape types.
Upgrading MapboxDirections from v1.x to v2.0.0
- The preferred way to set your Mapbox access token is to set the
MBXAccessTokenkey in your application’s Info.plist.MGLMapboxAccessTokenis still supported as a deprecated fallback. - The
Incident.impactproperty is now anIncident.Impactvalue instead of a string. RouteOptions.alleyPriority,RouteOptions.walkwayPriority, andRouteOptions.speedare now optional. Set them explicitly if you want to include them in the HTTP request. RenamedDirectionsOptions.defaulttoDirectionsOptions.medium.- Removed the
DirectionsResult.routeIdentifierproperty. Use theRouteResponse.identifierproperty in conjunction with an index into theRouteResponse.routesarray instead.
Upgrading MapboxSpeech from v1.x to v2.0.0
The preferred way to set your Mapbox access token is to set the MBXAccessToken key in your application’s Info.plist. MGLMapboxAccessToken is still supported as a deprecated fallback.
Upgrading from Mapbox Maps SDK v6.x to MapboxMaps v10.0.0
Mapbox Maps SDK v10 introduces 3D terrain, improves performance, and upgrades from OpenGL to Metal. Consult the v10 migration guide, which details many changes that likely affect your application’s user interface code.
Other changes:
- The preferred way to set your Mapbox access token is to set the
MBXAccessTokenkey in your application’s Info.plist.MGLMapboxAccessTokenis no longer supported.
Upgrading MapboxNavigation from v1.x to v2.0.0
Packaging
MapboxCoreNavigationno longer depends onMapboxAccounts.MapboxNavigationnow depends onMapboxMapsinstead ofMapbox.framework(Mapbox-iOS-SDKpod).- The
MBXNavigationBillingMethodInfo.plist key is no longer supported.
Map
The following symbols were renamed or replaced:
- Replaced the
NavigationMapView.navigationMapDelegateandNavigationMapView.navigationMapViewDelegateproperties with a singleNavigationMapView.delegateproperty. - Renamed the
NavigationViewController.mapViewproperty toNavigationViewController.navigationMapView. - Renamed the
MGLStyle.navigationDayStyleURLandMGLStyle.navigationNightStyleURLproperties toStyleURI.navigationDayandStyleURI.navigationNight, respectively. Removed theMGLStyle.navigationDayStyleURL(version:)andMGLStyle.navigationNightStyleURL(version:)methods in favor of these renamed properties. - Renamed the
NavigationMapView.highlightBuildings(at:in3D:)method toNavigationMapView.highlightBuildings(at:in3D:completion:).
Read more about using maps in the Navigation SDK v2.
Camera
The following symbols were renamed or replaced:
- Removed the
CarPlayNavigationViewController.tracksUserCourseproperty and theNavigationMapView.enableFrameByFrameCourseViewTracking(for:),NavigationMapView.updateCourseTracking(location:camera:animated:),NavigationMapView.setOverheadCameraView(from:along:for:), andNavigationMapView.recenterMap()methods in favor of theNavigationMapView.navigationCameraproperty. - Removed the
NavigationMapView.defaultAltitude,NavigationMapView.zoomedOutMotorwayAltitude,NavigationMapView.longManeuverDistance,NavigationMapView.defaultPadding,NavigationMapView.courseTrackingDelegate, andNavigationViewController.pendingCameraproperties and theNavigationMapViewDelegate.navigationMapViewUserAnchorPoint(_:)method in favor of theNavigationCamera.cameraStateTransitionproperty. NavigationMapView.updateCourseTracking(location:camera:animated:)accepts aCameraOptionsinstance instead of anMGLMapCameraobject.- Changed the
NavigationViewController.pendingCameraproperty’s type fromMGLMapCameratoCameraOptions.
Read more about how the camera works in the Navigation SDK v2.
User location indicator
The following symbols were renamed or replaced:
- Removed the
NavigationMapView.showsUserLocationandNavigationMapView.tracksUserCourseproperties in favor ofNavigationMapView.userLocationStyle. - Removed the
NavigationMapView.userCourseViewproperty in favor of the associated value whenNavigationMapView.userLocationStyleis set toUserLocationStyle.courseView(_:). - Renamed the
CourseUpdatable.update(location:pitch:direction:animated:tracksUserCourse:)method toCourseUpdatable.update(location:pitch:direction:animated:navigationCameraState:).
Route overlay
The following symbols were renamed or replaced:
- Removed the
NavigationAnnotationclass. - Renamed the
MBRouteLineWidthByZoomLevelproperty toConstants.RouteLineWidthByZoomLeveland changed its type toDoublefor keys and values. - Renamed the
MBCurrentLegAttributeandMBCongestionAttributeconstants toConstants.CurrentLegAttributeandConstants.CongestionAttribute, respectively. - Renamed the
NavigationMapView.updateRoute(_:)method toNavigationMapView.travelAlongRouteLine(to:). - Renamed the following waypoint styling delegate methods:
NavigationMapViewDelegate.navigationMapView(_:waypointCircleLayerWithIdentifier:source:)toNavigationMapViewDelegate.navigationMapView(_:waypointCircleLayerWithIdentifier:sourceIdentifier:)NavigationMapViewDelegate.navigationMapView(_:waypointSymbolLayerWithIdentifier:source:)toNavigationMapViewDelegate.navigationMapView(_:waypointSymbolLayerWithIdentifier:sourceIdentifier:)NavigationViewControllerDelegate.navigationViewController(_:waypointCircleLayerWithIdentifier:source:)toNavigationViewControllerDelegate.navigationViewController(_:waypointCircleLayerWithIdentifier:sourceIdentifier:)NavigationViewControllerDelegate.navigationViewController(_:waypointSymbolLayerWithIdentifier:source:)toNavigationViewControllerDelegate.navigationViewController(_:waypointSymbolLayerWithIdentifier:sourceIdentifier:)
- Removed the
NavigationViewController.originproperty.
Banners and guidance instructions
The following symbols were renamed or replaced:
- Removed the
InstructionsBannerViewDelegate.didDragInstructionsBanner(_:)method. - Removed the
StatusView.delegateandStatusView.canChangeValueproperties and theStatusViewDelegateandDeprecatedStatusViewDelegateprotocols. - Removed the
BottomBannerViewController(delegate:)initializer.
Read more about how maneuver instructions work in the Navigation SDK v2.
Location tracking
The following symbols were renamed or replaced:
- Renamed the
RouterDataSource.locationProviderandEventsManagerDataSource.locationProviderproperties toRouterDataSource.locationManagerTypeandActiveNavigationEventsManagerDataSource.locationManagerType, respectively. - Renamed the
Router.advanceLegIndex()method toRouter.advanceLegIndex(completionHandler:)and thePassiveLocationDataSource.updateLocation(_:)method toPassiveLocationManager.updateLocation(_:completion:). These methods are now asynchronous, and their completion handlers tell you whether the operation succeeded. - Removed the
RouteLegProgress.upComingStepproperty. - Removed the
NavigationViewController.indexedRoute,NavigationService.indexedRoute, andRouter.indexedRouteproperties in favor ofNavigationViewController.indexedRouteResponse,NavigationService.indexedRouteResponse, andRouter.indexedRouteResponse, respectively. These properties are no longer writable; use theRouter.updateRoute(with:routeOptions:completion:)method to manually reroute the user. - Removed the
RouteProgress.indexedRouteproperty. - The
NavigationService.routerandMapboxNavigationService.routerproperties are no longer unsafe-unowned. - Renamed the
Router.updateRoute(with:routeOptions:)method toRouter.updateRoute(with:routeOptions:completion:). The method is now asynchronous, with a new completion handler that is called when the update has completed. RouteOptionsno longer conforms toNSCopying. UseJSONEncoderandJSONDecoderto get a copy of theRouteOptionsobject round-tripped through JSON.- Renamed
RouteOptions.without(waypoint:)toRouteOptions.without(_:). - Removed
Bundle.ensureSuggestedTileURLExists(),Bundle.suggestedTileURLandBundle.suggestedTileURL(version:). - Removed the
Alertenumeration and theRouteAlert.alert,RouteAlert.distance,RouteAlert.length,RouteAlert.beginCoordinate,RouteAlert.endCoordinate,RouteAlert.beginSegmentIndex, andRouteAlert.endSegmentIndexproperties in favor of a consolidatedRouteAlerts.roadObjectproperty.
Read more about how location tracking works in the Navigation SDK v2.
Passive navigation
Passive navigation is also called free-drive navigation. The following symbols were renamed or replaced:
- Renamed
PassiveLocationManagertoPassiveLocationProviderandPassiveLocationDataSourcetoPassiveLocationManagerfor consistency withNavigationLocationProviderandNavigationLocationManager. PassiveLocationProvidernow conforms to theLocationProviderprotocol instead ofMGLLocationManager.- The
PassiveLocationProvider.delegateproperty is now of typeLocationProviderDelegateinstead ofMGLLocationManagerDelegate. - Replaced
PassiveLocationManager.accuracyAuthorization()with thePassiveLocationProvider.accuracyAuthorizationproperty, which now returnsCLAccuracyAuthorizationinstead ofMBNavigationAccuracyAuthorization. - Renamed
PassiveLocationManager.startUpdatingLocation(completionHandler:)toPassiveLocationProvider.startUpdatingLocation(). This method now runs synchronously likeCLLocationManager.startUpdatingLocation().
Read more about how free-drive navigation, also referred to as passive navigation, works in the Navigation SDK v2.
CarPlay
The following symbols were renamed or replaced:
- Removed the
CarPlayNavigationDelegate.carPlayNavigationViewControllerDidArrive(_:)method. - Renamed the
CarPlayManager.mapViewproperty toCarPlayManager.navigationMapView. - Removed the
CarPlayManager.overviewButtonproperty. - Removed the
CarPlayNavigationViewController.drivingSideproperty. - Renamed the
CarPlayNavigationDelegateprotocol toCarPlayNavigationViewControllerDelegateand theCarPlayNavigationViewController.carPlayNavigationDelegateproperty toCarPlayNavigationViewController.delegate. - The
CarPlayNavigationViewController.styleManagerandCarPlayMapViewController.styleManagerproperties are now read-only. - Moved the
CarPlaySearchController.searchTemplate(_:updatedSearchText:completionHandler:),CarPlaySearchController.searchTemplate(_:searchTemplate:selectedResult:completionHandler:)methods to theCarPlaySearchControllerDelegateprotocol. Renamed theCarPlaySearchControllerDelegate.resultsOrNoResults(_:limit:)method toCarPlaySearchControllerDelegate.searchResults(with:limit:). - Renamed the
CarPlayManagerDelegate.carPlayManager(_:navigationServiceAlong:routeIndex:routeOptions:desiredSimulationMode:)method toCarPlayManagerDelegate.carPlayManager(_:navigationServiceFor:routeIndex:routeOptions:desiredSimulationMode:). It now returns an optionalNavigationService; if it isnil, aMapboxNavigationServicewill be used by default. - Renamed the
CarPlayManagerDelegate.carplayManagerShouldDisableIdleTimer(_:)method toCarPlayManagerDelegate.carPlayManagerShouldDisableIdleTimer(_:).
Read more about how CarPlay integration works in the Navigation SDK v2.
User feedback
The following symbols were renamed or replaced:
- The
ActiveNavigationEventsManagerDataSource.router,NavigationService.eventsManager, andMapboxNavigationService.eventsManagerproperties are no longer unsafe-unowned. - Removed the
EventsManagertype alias. - Renamed the
FeedbackViewController(eventsManager:)initializer toFeedbackViewController(eventsManager:type:). You can now customize the view controller to show only the feedback types specific to passive navigation. - Renamed the
FeedbackTypeenumeration toActiveNavigationFeedbackTypeand theEventsManagerDataSourceprotocol toActiveNavigationEventsManagerDataSource.
Read more about how user feedback works in the Navigation SDK v2.
Other migration steps
Configuring storyboards
If your storyboard has a segue to NavigationViewController in Navigation.storyboard, you have to call the NavigationViewController.prepareViewLoading(routeResponse:routeIndex:routeOptions:navigationOptions:) method in your implementation of the UIViewController.prepare(for:sender:) method.
Tile cache cleanup
When migrating make sure you have cleaned up the old navigation tiles cache folder to reclaim disk space:
- Navigation SDK v2 caches navigation tiles in a default folder under
<APP_FOLDER>/Library/Caches/<APP_BUNDLE_ID>/tiles. - Previous versions of Navigation SDK cache tiles in a default folder under
<APP_FOLDER>/Library/Caches/<APP_BUNDLE_ID>/.mapbox. - Caches from previous versions of the Navigation SDK are not compatible with v2.
- Delete any folders used for caching with previous versions of the SDK including a default one.
NavigationSettings.shared.tileStoreConfigurationenables you to specify a path where navigation and map tiles will be saved. If a custom directory was used, you should remove it, too.- Be sure to configure the custom path before starting a free drive or an active guidance session if you don't want to use the default location.
Migrating a project from framework bundles to XCFrameworks
Switching from discrete framework bundles to XCFrameworks requires a few changes to your project. Follow these migration steps to switch:
- Delete your
Carthagefolder to remove any existing framework bundles. - Build new XCFrameworks by running
carthage bootstrap --platform iOS --use-xcframeworks --use-netrc. - Remove references to the old frameworks in each of your targets:
- Delete references to Carthage frameworks from the target's Frameworks, Libraries, and Embedded Content section and/or its Link Binary with Libraries build phase.
- Delete references to Carthage frameworks from any Copy Files build phases.
- Delete the target's
carthage copy-frameworksbuild phase, if present.
- Add references to XCFrameworks in each of your targets:
- For an application target: In the General settings tab, in the Frameworks, Libraries, and Embedded Content section, drag and drop each XCFramework you use from the Carthage/Build folder on disk.
- For a framework target: In the Build Phases tab, in a Link Binary with Libraries phase, drag and drop each XCFramework you use from the Carthage/Build folder on disk.
Need help?
If you have any questions, contact Mapbox’s support team.