Migrate Core
Mapbox Navigation SDK v3 for iOS is a new generation of the core functionality available in Navigation SDK v2. To install the latest version of the SDK, follow the installation instructions and use this guide to update your application from v2 to v3. Note that the API of Mapbox Navigation SDK v3 is not stable yet, the guide describes migration to the latest version and will be updated in case of API changes.
Requirements and dependencies changes
The Navigation SDK v3 for iOS is compatible with applications that:
- Are built using Swift 5.9 or higher.
- Are built using Xcode 15.0 or higher.
The MapboxNavigationCore framework works on iOS 14.0 and above.
Maps SDK
The Navigation SDK v3 uses the Mapbox Maps SDK v11, as opposed to Maps SDK v10 in the Navigation SDK v2. Maps SDK v11 offers the new Mapbox Standard and Standard Satellite style support, new 3D features, improved performance and a lot more.
Maps SDK v11 is a SEMVER major release with breaking API changes. If the application you are migrating uses a map, make sure you read the Maps SDK migration guide before reading the navigation-specific content below.
Upgrade your application from the Mapbox Maps SDK for iOS v10 to v11.
Major changes in the Navigation SDK v3 since Navigation SDK v2
SDK Configuration
NavigationSettings
is no longer available and is replaced with CoreConfig
structure which consolidates all SDK configurations. It is now mandatory to provide this setting on SDK initialization. CoreConfig
can be also updated at runtime, but it is not recommended as different parts of settings may be applied asynchronously and independently from each other, resulting in undesired behavior and/or UI appearance.
CoreConfig
contains some sub-structures which are designed to control dedicated use-cases.
MapboxNavigation
MapboxNavigation
is the main facade of the SDK. Comparing to v2 SDK it supersedes the NavigationService
and Router
. It handles the Navigator
, provides control over it as well as reporting navigation events.
Your typical interaction with the SDK starts like this:
let coreConfig = CoreConfig(/* ... */) // your configuration
let mapboxNavigationProvider = MapboxNavigationProvider(coreConfig: coreConfig)
let mapboxNavigation = mapboxNavigationProvider.mapboxNavigation
Lifecycle
MapboxNavigation
reference (or its MapboxNavigationProvider
) must be maintained by the user for as long as any of SDK functionality is needed. It is acceptable to re-instantiate it but not recommended, as it is an expensive action.
Multiple instances of MapboxNavigation
are not allowed and having that is considered a programmer error. The SDK will flag an error whenever it detects such a case.
NavigationService
& Router
replacement
NavigationService
, Router
and PassiveLocationManager
were the main sources of control over the SDK behavior and usage. These were used to start and stop Free Drive and Active Guidance, apply routes, switch legs and handle the outputs. It is now moved to MapboxNavigation
s sub-interfaces, which are divided by use-cases. Each component has corresponding methods to trigger related actions.
SDK v2 reported events via delegates (RouterDelegate
, NavigationServiceDelegate
) and some NotificationCenter
notifications. These are no longer available and are replaced with Combine
publishers, which are divided by it's purpose and are available as components of MapboxNavigation
object.
Next is the list of available MapboxNavigation
components:
routingProvider()
Used to do route requests. It's functionality is equivalent to v2 RoutingProvider
.
It does not publish any events.
tripSession()
This controller is used to do a high-level operation on the navigator like entering Free Drive or Active Guidance modes.
Available events publishers:
-
Reports currently active navigation session state. This has no analogs in SDK v2.
-
Reports current
NavigationRoutes
set to the navigation. Can be used to replaceRouter.route
,NavigationService.route
orNavigationService.indexedRouteResponse
updates.
electronicHorizon()
This controller to toggle Electronic Horizon, and handle it's related road data.
Available events publishers:
-
Reports similar events to
electronicHorizonDidUpdatePosition
,electronicHorizonDidEnterRoadObject
,electronicHorizonDidExitRoadObject
andelectronicHorizonDidPassRoadObject
notifications.