Getting an error on launching Carplay App - *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Application does not implement CarPlay template application lifecycle methods in its scene delegate.'

I have a SwiftUI app, and Apple has approved the Carplay entitlement. The entitlement integration is done successfully, however when I try to launch the carplay app I get the below error

*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Application does not implement CarPlay template application lifecycle methods in its scene delegate.'

Info.plist:

<key>UIApplicationSceneManifest</key> <dict> <key>UIApplicationSupportsMultipleScenes</key> <true/> <key>UISceneConfigurations</key> <dict> <key>CPTemplateApplicationSceneSessionRoleApplication</key> <array> <dict> <key>UISceneConfigurationName</key> <string>Default Configuration</string> <key>UISceneDelegateClassName</key> <string>$(PRODUCT_MODULE_NAME).CarPlaySceneDelegate</string> </dict> </array> </dict> </dict>

In AppDelegate I have the below

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { if connectingSceneSession.role == .carTemplateApplication { let sceneConfiguration = UISceneConfiguration(name: "CarPlay Scene", sessionRole: connectingSceneSession.role) sceneConfiguration.delegateClass = CarPlaySceneDelegate.self return sceneConfiguration }

    // Configuration for other types of scenes
    return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

Why am I getting the exception? Kindly suggest

Answered by Frameworks Engineer in 807816022

You need to implement the CPTemplateApplicationSceneDelegate methods in your scene delegate. In the example above, that would be your CarPlaySceneDelegate class.

In particular, you need to implement templateApplicationScene:didConnectInterfaceController: to receive an interface controller, which your app can use to present and manage templates.

Please see the CarPlay developer guide and CarPlay documentation for more details.

You need to implement the CPTemplateApplicationSceneDelegate methods in your scene delegate. In the example above, that would be your CarPlaySceneDelegate class.

In particular, you need to implement templateApplicationScene:didConnectInterfaceController: to receive an interface controller, which your app can use to present and manage templates.

Please see the CarPlay developer guide and CarPlay documentation for more details.

Getting an error on launching Carplay App - *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Application does not implement CarPlay template application lifecycle methods in its scene delegate.'
 
 
Q