> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/ios/ja/navigation/llms.txt)

# Migrate CarPlay

# Major changes in the CarPlay logic in the Navigation SDK v3 since Navigation SDK v2

## `CarPlayManager`

### initializes

-   The main difference is that the old deprecated initializes have been removed and added new initializes for creating `CarPlayManager`. To get instance of [`MapboxNavigationProvider`](https://docs.mapbox.com/ios/navigation/api/3.28.2/navigation/documentation/mapboxnavigationcore/mapboxnavigationprovider/) reach out the main [migration guide for SDK v3](https://docs.mapbox.com/ios/ja/navigation/guides/get-started/install/)

```swift
   @MainActor init(navigationProvider: MapboxNavigationProvider, styles: [Style]? = nil)
```

### Properties

-   [`directions`](https://docs.mapbox.com/ios/navigation/api/1.4.2/Classes/CarPlayManager.html#/s:16MapboxNavigation14CarPlayManagerC10directions0A10Directions0G0Cvp) have been removed. If you want to get any information about current route, use [`RoutingProvider()`](https://docs.mapbox.com/ios/navigation/api/3.28.2/navigation/documentation/mapboxnavigationcore/mapboxnavigation/routingprovider()/) instead.

```swift
   var directions: Directions
```

-   [`routingProvider`](https://docs.mapbox.com/ios/navigation/api/1.4.2/Classes/CarPlayManager.html#/s:16MapboxNavigation14CarPlayManagerC15routingProvider0a4CoreB007RoutingG0_pvp) have been removed. If you want to get any information about current route, use new instance of [`RoutingProvider()`](https://docs.mapbox.com/ios/navigation/api/3.28.2/navigation/documentation/mapboxnavigationcore/mapboxnavigation/routingprovider()/) instead.

```swift
   var routingProvider: RoutingProvider
```

-   [`simulatesLocations`](https://docs.mapbox.com/ios/navigation/api/1.4.2/Classes/CarPlayManager.html#/s:16MapboxNavigation14CarPlayManagerC18simulatesLocationsSbvp) and [`simulatedSpeedMultiplier`](https://docs.mapbox.com/ios/navigation/api/1.4.2/Classes/CarPlayManager.html#/s:16MapboxNavigation14CarPlayManagerC24simulatedSpeedMultiplierSdvp) have been removed. CarPlay Navigation SDK v3 does not support location simulation configuration for now.

```swift
   var simulatesLocations: Bool
   var simulatedSpeedMultiplier: Bool
```

#### Methods

-   From method [`beginNavigationWithCarPlay`](https://docs.mapbox.com/ios/navigation/api/1.4.2/Classes/CarPlayManager.html#/s:16MapboxNavigation14CarPlayManagerC05beginb4WithcD05using17navigationServiceySo22CLLocationCoordinate2DV_0a4CoreB00bJ0_ptF) removed parameter [`navigationService`](https://docs.mapbox.com/ios/navigation/api/1.4.2/Protocols/NavigationService.html). If you want to get information about your current route, use [`tripSession()`](https://docs.mapbox.com/ios/navigation/api/3.28.2/navigation/documentation/mapboxnavigationcore/mapboxnavigation/tripsession()/) instead.

```swift
   func beginNavigationWithCarPlay(using currentLocation: CLLocationCoordinate2D)
```

## `CarPlayManagerDelegate`

### Methods

-   The following methods are deprecated now. If you need to get information about your navigation progress use new [`tripSession()`](https://docs.mapbox.com/ios/navigation/api/3.28.2/navigation/documentation/mapboxnavigationcore/mapboxnavigation/tripsession()/) object instead.

```swift
   func carPlayManager(_ carPlayManager: CarPlayManager,
                        routeResponse: RouteResponse,
                        routeIndex: Int,
                        routeOptions: RouteOptions,
                        desiredSimulationMode: SimulationMode) -> NavigationService?

   func carPlayManager(_ carPlayManager: CarPlayManager,
                        navigationServiceFor indexedRouteResponse: IndexedRouteResponse,
                        desiredSimulationMode: SimulationMode) -> NavigationService?

```

-   The following methods are removed: `CarPlayManagerDelegate` does not support custom `LineLayer`, `CircleLayer` and `SymbolLayer` for configuration custom destination pins and waypoints.

```swift
   func carPlayManager(_ carPlayManager: CarPlayManager,
                        routeLineLayerWithIdentifier identifier: String,
                        sourceIdentifier: String,
                        for parentViewController: UIViewController) -> LineLayer?

   func carPlayManager(_ carPlayManager: CarPlayManager,
                           routeCasingLineLayerWithIdentifier identifier: String,
                           sourceIdentifier: String,
                           for parentViewController: UIViewController) -> LineLayer?

   func carPlayManager(_ carPlayManager: CarPlayManager,
                           routeRestrictedAreasLineLayerWithIdentifier identifier: String,
                           sourceIdentifier: String,
                           for parentViewController: UIViewController) -> LineLayer?

   func carPlayManager(_ carPlayManager: CarPlayManager,
                           waypointCircleLayerWithIdentifier identifier: String,
                           sourceIdentifier: String) -> CircleLayer?

   func carPlayManager(_ carPlayManager: CarPlayManager,
                        waypointSymbolLayerWithIdentifier identifier: String,
                        sourceIdentifier: String) -> SymbolLayer?

```

-   Since [`NavigationService`](https://docs.mapbox.com/ios/navigation/api/1.4.2/Protocols/NavigationService.html) does not exists on Navigation SDK v3 the following method has been changed:

```swift
   func carPlayManagerDidBeginNavigation(_ carPlayManager: CarPlayManager)
```

-   In Navigation SDK v3 method `didFailToFetchRouteBetween` use type erasure to hide error specification. New method signature looks like this:

```swift
   func carPlayManager(_ carPlayManager: CarPlayManager,
                        didFailToFetchRouteBetween waypoints: [Waypoint]?,
                        options: RouteOptions,
                        error: Error) -> CPNavigationAlert?
```

## `CarPlayMapViewController`

### initializes

-   Since Navigation SDK v3 use global object which called [`MapboxNavigation`](https://docs.mapbox.com/ios/navigation/api/3.28.2/navigation/documentation/mapboxnavigationcore/mapboxnavigation/). You have to inject this object inside `CarPlayMapViewController` to help map own some underneath logic related to tile loading, puck movement and other low level things.

```swift
   init(core: MapboxNavigation, styles: [Style])
```

## `CarPlayMapViewControllerDelegate`

### Methods

-   The following methods are removed: `CarPlayMapViewControllerDelegate` does not support custom `LineLayer` for detailed customization for now.

```swift
   func carPlayMapViewController(_ carPlayMapViewController: CarPlayMapViewController,
                                    willAdd layer: Layer) -> Layer?
   func carPlayMapViewController(_ carPlayMapViewController: CarPlayMapViewController,
                                    routeRestrictedAreasLineLayerWithIdentifier identifier: String,
                                    sourceIdentifier: String) -> LineLayer?
   func carPlayMapViewController(_ carPlayMapViewController: CarPlayMapViewController,
                                    routeCasingLineLayerWithIdentifier identifier: String,
                                    sourceIdentifier: String) -> LineLayer?
   func carPlayMapViewController(_ carPlayMapViewController: CarPlayMapViewController,
                                    routeLineLayerWithIdentifier identifier: String,
                                    sourceIdentifier: String) -> LineLayer?
```

## `CarPlayNavigationViewController`

### initializes

-   The initializer remained almost the same but now required [`MapboxNavigation`](https://docs.mapbox.com/ios/navigation/api/3.28.2/navigation/documentation/mapboxnavigationcore/mapboxnavigation/) object and `AccessToken` to get information about your current navigation progress.

```swift
   init(
        accessToken: String,
        core: MapboxNavigation,
        mapTemplate: CPMapTemplate,
        interfaceController: CPInterfaceController,
        manager: CarPlayManager,
        styles: [Style]? = nil,
        navigationRoutes: NavigationRoutes
    )
```

### Properties

-   The property of [`navigationService`](https://docs.mapbox.com/ios/navigation/api/1.4.2/Protocols/NavigationService.html) does not longer exists. If you want to get the information about your current navigation progress use [`MapboxNavigation`](https://docs.mapbox.com/ios/navigation/api/3.28.2/navigation/documentation/mapboxnavigationcore/mapboxnavigation/) instead.

```swift
   var navigationService: NavigationService
```

## `CarPlayNavigationViewControllerDelegate`

### Methods

-   The following methods are removed: `CarPlayNavigationViewControllerDelegate` does not support custom `LineLayer`, `CircleLayer` and `SymbolLayer` for configuration custom destination pins and waypoints.

```swift
   func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController,
                                         routeLineLayerWithIdentifier identifier: String,
                                         sourceIdentifier: String) -> LineLayer?
   func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController,
                                          waypointSymbolLayerWithIdentifier identifier: String,
                                          sourceIdentifier: String) -> SymbolLayer?
   func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController,
                                          waypointCircleLayerWithIdentifier identifier: String,
                                          sourceIdentifier: String) -> CircleLayer?
   func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController,
                                          routeCasingLineLayerWithIdentifier identifier: String,
                                          sourceIdentifier: String) -> LineLayer?
   func carPlayNavigationViewController(_ carPlayNavigationViewController: CarPlayNavigationViewController,
                                          willAdd layer: Layer) -> Layer?
```