2022 SwiftUI & UI FrameworksApp Services
WWDC22 · 21 min · SwiftUI & UI Frameworks / App Services
Get more mileage out of your app with CarPlay
CarPlay is a smarter, safer way to use your iPhone while you drive. Learn about the latest app types for CarPlay and discover how the CarPlay Simulator can help you develop and test apps without leaving your desk. We’ll also explore how navigation apps can connect with digital instrument clusters in supported vehicles.
Watch at developer.apple.com ↗Code shown on screen · 2 snippets
Application scene manifest
<key>UIApplicationSceneManifest</key>
<dict>
<!-- Indicate support for CarPlay dashboard -->
<key>CPSupportsDashboardNavigationScene</key>
<true/>
<!-- Indicate support for instrument cluster displays -->
<key>CPSupportsInstrumentClusterNavigationScene</key>
<true/>
<!-- Indicate support for multiple scenes -->
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<!-- For device scenes -->
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneClassName</key>
<string>UIWindowScene</string>
<key>UISceneConfigurationName</key>
<string>Phone</string>
<key>UISceneDelegateClassName</key>
<string>MyAppWindowSceneDelegate</string>
</dict>
</array>
<!-- For the main CarPlay scene -->
<key>CPTemplateApplicationSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneClassName</key>
<string>CPTemplateApplicationScene</string>
<key>UISceneConfigurationName</key>
<string>CarPlay</string>
<key>UISceneDelegateClassName</key>
<string>MyAppCarPlaySceneDelegate</string>
</dict>
</array>
<!-- For the CarPlay Dashboard scene -->
<key>CPTemplateApplicationDashboardSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneClassName</key>
<string>CPTemplateApplicationDashboardScene</string>
<key>UISceneConfigurationName</key>
<string>CarPlay-Dashboard</string>
<key>UISceneDelegateClassName</key>
<string>MyAppCarPlayDashboardSceneDelegate</string>
</dict>
</array>
<!-- For the CarPlay instrument cluster scene -->
<key>CPTemplateApplicationInstrumentClusterSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneClassName</key>
<string>CPTemplateApplicationInstrumentClusterScene</string>
<key>UISceneConfigurationName</key>
<string>CarPlay-Instrument-Cluster</string>
<key>UISceneDelegateClassName</key>
<string>MyAppCarPlayInstrumentClusterSceneDelegate</string>
</dict>
</array>
</dict>
</dict> Application instrument cluster scene delegate
extension TemplateApplicationSceneDelegate: CPTemplateApplicationInstrumentClusterSceneDelegate {
func templateApplicationInstrumentClusterScene(
_ templateApplicationInstrumentClusterScene: CPTemplateApplicationInstrumentClusterScene,
didConnect instrumentClusterController: CPInstrumentClusterController) {
// Connected to Instrument Cluster
TemplateManager.shared.clusterController(instrumentClusterController, didConnectWith: templateApplicationInstrumentClusterScene.contentStyle)
}
…
func instrumentClusterControllerDidConnect(_ instrumentClusterWindow: UIWindow) {
// Window in which to draw instrument cluster contents
self.instrumentClusterWindow = instrumentClusterWindow
} Resources
Related sessions
-
18 min -
26 min -
39 min