Displaying Content in CarPlay
Use scenes to present your app’s content on the vehicle’s built-in screen.
Overview
A scene manages your CarPlay-enabled app’s user interface, including the window that CarPlay displays on the vehicle’s screen. Navigation apps are the only app category that have access to this window, and use it to draw their map content. All other categories of apps use only the scene’s interface controller to manage their user interface.
As CarPlay manages your app’s scene, you provide a scene delegate — an object that conforms to the CPTemplateApplicationSceneDelegate protocol — that the system notifies about scene life cycle events. CarPlay creates your app’s scene and scene delegate when the user launches your app.
Add a CarPlay Scene
To add a CarPlay scene, provide its configuration in the scene manifest of your Xcode project’s Info.plist file. Specify your scene delegate’s class name as the value of the UISceneDelegateClassName key.
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>CPTemplateApplicationSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneClassName</key>
<string>CPTemplateApplicationScene</string>
<key>UISceneConfigurationName</key>
<string>MyCarPlaySceneConfiguration</string>
<key>UISceneDelegateClassName</key>
<string>MyCarPlaySceneDelegate</string>
</dict>
</array>
</dict>
</dict> In your scene delegate, implement the templateApplicationScene(_:didConnect:) method and use the interface controller that it provides to set your root template.
If your app specifies the navigation entitlement, implement the templateApplicationScene(_:didConnect:to:) method instead because it provides a reference to your app’s window that CarPlay manages. Create an instance of your map-drawing view controller and set it as the window’s root view controller. Make sure that you set your interface controller’s root template.
Add a CarPlay Dashboard Scene
Navigation apps can add an additional scene entry to their scene manifest to enable their maps, upcoming maneuvers, and shortcut buttons to appear in the CarPlay Dashboard.
Add the following key to the UIApplicationSceneManifest dictionary in your Xcode project’s Info.plist file to specify that your app supports the CarPlay Dashboard:
<key>UIApplicationSceneManifest</key>
<dict>
<key>CPSupportsDashboardNavigationScene</key>
<true/>
</dict>In the same file, add the CarPlay Dashboard scene configuration to the UISceneConfigurations dictionary. Provide your dashboard scene delegate’s class name as the value of the UISceneDelegateClassName key.
<key>CPTemplateApplicationDashboardSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneClassName</key>
<string>CPTemplateApplicationDashboardScene</string>
<key>UISceneConfigurationName</key>
<string>MyCarPlayDashboardSceneConfiguration</string>
<key>UISceneDelegateClassName</key>
<string>MyCarPlayDashboardSceneDelegate</string>
</dict>
</array>In your dashboard scene delegate, implement templateApplicationDashboardScene(_:didConnect:to:). Use the window that the method provides to render your map content. Set the dashboard controller’s shortcutButtons property to an array of buttons — up to a maximum of two — that the CarPlay Dashboard displays when your app isn’t actively navigating.