We are extending our Xamarin.iOS app (by Xamarin.Forms) for CarPlay. When open the CarPlay simulator, the app is showing on the screen of CarPlay, but crashed when launching from CarPlay simulator.
Below is the Info.plist Scene configuration:
<key>UIApplicationSceneManifest</key>
<dict>
<key>UISceneConfigurations</key>
<dict>
<key>CPTemplateApplicationSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneClassName</key>
<string>CPTemplateApplicationScene</string>
<key>UISceneConfigurationName</key>
<string>ParkingPlus-Car</string>
<key>UISceneDelegateClassName</key>
<string>ParkingPlus.AppSceneDelegateImp</string>
</dict>
</array>
</dict>
</dict>
"ParkingPlus" is the app bundle name!
The class AppSceneDelegateImp (under the root folder of the iOS project
public class AppSceneDelegateImp : UIResponder, ICPTemplateApplicationSceneDelegate
{
private CPInterfaceController _interfaceController;
public async void DidConnect(CPTemplateApplicationScene templateApplicationScene, CPInterfaceController interfaceController)
{
_interfaceController = interfaceController;
.....
}
public void DidDisconnect(CPTemplateApplicationScene templateApplicationScene, CPInterfaceController interfaceController)
{
_interfaceController.Dispose();
_interfaceController = null;
}
}
When I override the AppDelegate.GetConfiguration as below
public override UISceneConfiguration GetConfiguration(UIApplication application, UISceneSession connectingSceneSession, UISceneConnectionOptions options)
{
...
}
When tapping the app icon on CarPlay, the method will be called. But when I inspected the connectingSceneSession, I found there are some exceptions inside the variable members. "CPTemplateApplicationSceneSessionRoleApplication has no associated enum value on this platform".
Screenshot for connectingSceneSession inspection
If continue, then the app will throw an exception which seems advise that the SceneDelegate is not being loaded properly: Exception
My envorinment: Visual studio for mac Version 8.7.8 Xamarin.iOS 14.0.0 Xcode 12.0
It seems like Xamarin.ios 14 missing something when binding the iOS library. Anyone has the similar issue. Did I do anything wrong or Is there any other way I can implement the CarPlay part feature by Xcode/swift while keeping the mobile app on Xamarin.Forms/Xamarin.iOS?
Appreciate any comments or help.
With the help from Xamarin.ios team, below is the full solution to this issue: https://github.com/xamarin/xamarin-macios/issues/9749