Application does not implement CarPlay template application lifecycle methods in its scene delegate

Hello,

I've been banging my head against this for a couple of days now

I can't get the CarPlay interface to work on my music app

I see the error: Application does not implement CarPlay template application lifecycle methods in its scene delegate

I've checked the sample code and developer guides and can't see my mistake

My CarPlay delegate code is:

class CarPlaySceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate {
var interfaceController: CPInterfaceController?
var carPlayWindow: UIWindow?
private let playerManager = MusicPlayerManager.shared
private var playlists: MusicItemCollection<Playlist> = []
// MARK: - CPTemplateApplicationSceneDelegate Methods
func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene,
didConnect interfaceController: CPInterfaceController) {
// Store reference to the interface controller to use throughout the app
self.interfaceController = interfaceController
// Request Apple Music authorization if needed
requestMusicAuthorization()
// Configure the interface with the now playing template and specified tabs
setupCarPlayInterface(interfaceController)
}
func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene,
didDisconnectInterfaceController interfaceController: CPInterfaceController) {
// Clean up when CarPlay disconnects
self.interfaceController = nil
print("CarPlay disconnected")
}
func sceneDidBecomeActive(_ scene: UIScene) {
// Called when the scene has moved from an inactive state to an active state
print("CarPlay scene became active")
}

etc

My info.plist contains:

<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>TemplateSceneConfiguration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).CarPlaySceneDelegate</string>
</dict>
</array>
</dict>
</dict>

My one doubt is this entry in the plist: UISceneConfigurationName as I can't find any clarity in the docs how to use or implement this

Can anyone suggest where I need to be looking?

Thanks for your help!

Hi, it looks like the system might be having some trouble finding your scene delegate class. Do you have multiple modules in the app? Do you see the system instantiating your CarPlaySceneDelegate class at all?

What is the value of PRODUCT_MODULE_NAME in this target? It might also be worth specifying only CarPlaySceneDelegate on its own for the UISceneDelegateClassName.

Hello

I tried adjusting the info.plist to remove PRODUCT_MODULE_NAME and it made no difference

I added a debug print command to be the first instruction inside

func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene,
didConnect interfaceController: CPInterfaceController) {
print("🚙 CarPlay connected")

and I do not ever see that log message so I guess the class is not being instantiated

as far as I can tell the CarPlay delegate is configured correctly but I am still seeing this crash.

What should I check or test next?

Thanks for your help

Mark

Application does not implement CarPlay template application lifecycle methods in its scene delegate
 
 
Q