Can you share your project with me, please? Sorry, I cannot share my project because I work to create in my company.
Instead, I share more detailed procedure that I tried.
https://developer.apple.com/forums/thread/664597 I share the following procedure that uses above your code as an example.
#1 Create a new Xcode project
Choose a template for your new project: Select [iOS] -> [App]
Choose options for your new project:
Product Name : mytestapp
Organization Identifier: com.<your-name>
Interface: Storyboard
LifeCycle: UIKit App Delegate
Language: Swift
#2 Add an entitlement file to your project
Add new file from Xcode menu [File] -> [New] -> [File...]
And select [iOS] -> [Property List]
Save as: mytestapp.entitlements
mytestapp.entitlements like this
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.developer.carplay-calling</key>
<true/>
<key>com.apple.developer.carplay-communication</key>
<true/>
<key>com.apple.developer.siri</key>
<true/>
</dict>
</plist>
And set entitlement file path to Build Settings.
Select [mytestapp] -> TARGETS [mytestapp] -> [Build Settings] -> [All]
Set "Code Signing Entitlements" to your entitlement file path.
#3 Edit "Info.plist"
Declare CarPlay scene to "Scene Configuration" like the following.
<key>UISceneConfigurations</key>
<dict>
<key>CPTemplateApplicationSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneClassName</key>
<string>CPTemplateApplicationScene</string>
<key>UISceneConfigurationName</key>
<string>CarPlay Configuration</string>
<key>UISceneDelegateClassName</key>
<string>${PRODUCT_MODULE_NAME}.CarPlaySceneDelegate</string>
</dict>
</array>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
<key>UISceneStoryboardFile</key>
<string>Main</string>
</dict>
</array>
</dict>
#4 Enable CarPlay icon setting
Select [Assets.xcassets] -> [AppIcon] and enable a "CarPlay" checkbox.
#5 Implement CarPlaySceneDelegate
CarPlaySceneDelegate.swift like this
import CarPlay
class CarPlaySceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate {
		var interfaceController: CPInterfaceController?
		// CarPlay connected
		func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didConnect interfaceController: CPInterfaceController) {
				self.interfaceController = interfaceController
				let contact = CPContact(name: "TEST", image: UIImage(named: "Person.jpg")!)
				let template = CPContactTemplate(contact: contact)
				self.interfaceController?.setRootTemplate(template, animated: false, completion: nil)
		}
		// CarPlay disconnected
		private func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene, didDisconnect interfaceController: CPInterfaceController) {
				self.interfaceController = nil
		}
}
And add any Person.jpg file to your project.
#6 Add an Intents App Extension to your project
Choose Xcode [File] > [New] > [Target...] and select "Intents Extension".
Product Name: myintentextension
Language: Swift
Stating Point: Messaging (Default)
If you create above "Intents Extension", "Activate scheme" dialog shows.
Select Activate.
And then, set iOS version to "TARGETS".
In my case, my iPhone device version is iOS 14.0, so I set it as follows.
TARGETS :
mytestapp : iOS 14.0
myintentextension : iOS 14.0
myintentextensionUI : iOS 14.0
"myintentextension" and "myintentextensionUI" directories and source code are generated automatically.
Currently, my Xcode project uses intents that are generated automatically.
(In the future, I will implement intents what I want to do.)
#7 Build and install app.
Build and install your app to the simulator or iPhone real device and run it.
If you would like to run on the iPhone real device,
you create a provisioning profile includes CarPlay communication entitlement.
And import it to your project.
In my case, I imported a provisioning profile and set manually.
My environment
Xcode version : 12.1
iOS version : 14.0