0

I'm new in iOS development. Got task on job to extend our iOS app with CarPlay. I created class 'CarPlaySceneDelegate' as entry point for Car Play. Code is below:

class CarPlaySceneDelegate: UIResponder, CPTemplateApplicationSceneDelegate {
    var interfaceController: CPInterfaceController?
    
    func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene,
                                  didConnect interfaceController: CPInterfaceController) {
        self.interfaceController = interfaceController
        ...
        interfaceController.setRootTemplate(tabBarTemplate, animated: true)
        
  }        

    private func templateApplicationScene(_ templateApplicationScene: CPTemplateApplicationScene,
          didDisconnect interfaceController: CPInterfaceController) {
          self.interfaceController = nil
    }
}

To Info.plist I added this configuration:

<key>UIApplicationSceneManifest</key>
    <dict>
        <key>UIApplicationSupportsMultipleScenes</key>
        <true/>
        <key>UISceneConfigurations</key>
        <dict>
            <key>UIWindowSceneSessionRoleApplication</key>
            <array>
                <dict>
                    <key>Configuration Name</key>
                    <string>Default configuration</string>
                    <key>Delegate Class Name</key>
                    <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
                    <key>Storyboard Name</key>
                    <string>Main</string>
                </dict>
            </array>
            <key>CPTemplateApplicationSceneSessionRoleApplication</key>
            <array>
                <dict>
                    <key>UISceneClassName</key>
                    <string>CPTemplateApplicationScene</string>
                    <key>UISceneConfigurationName</key>
                    <string>BlueGate-Car</string>
                    <key>UISceneDelegateClassName</key>
                    <string>$(PRODUCT_MODULE_NAME).CarPlaySceneDelegate</string>
                </dict>
            </array>
        </dict>
    </dict>

On launching on simulator CarPlay launches good according to CarPlaySceneDelegate class. But on iPhone Simulator it's not launched at all. App loads and screen become black.

In console:

2021-11-03 12:45:11.228204+0200 BlueGate[5806:119147]  - <AppMeasurement>[I-ACS036001] Analytics screen reporting is disabled. UIViewController transitions will not be logged.
2021-11-03 10:45:11 +0000 [AppDelegate.swift]:[application(_:didFinishLaunchingWithOptions:)][103:19] start function
2021-11-03 12:45:11.714422+0200 BlueGate[5806:118883] [Firebase/Crashlytics] Version 8.7.0
2021-11-03 12:45:12.108628+0200 BlueGate[5806:119153] 8.7.0 - [Firebase/Analytics][I-ACS023007] Analytics v.8.7.0 started
2021-11-03 12:45:12.119347+0200 BlueGate[5806:119153] 8.7.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://<someLink>)
2021-11-03 12:45:12.140585+0200 BlueGate[5806:119154] 8.7.0 - [Firebase/Analytics][I-ACS025036] App Delegate Proxy is disabled
2021-11-03 10:45:12 +0000 [AppDelegate.swift]:[configureNetworkMonitoring()][89:35] Network is ON
2021-11-03 12:45:12.316632+0200 BlueGate[5806:119154] 8.7.0 - [Firebase/Messaging][I-FCM002022] APNS device token not set before retrieving FCM Token for Sender ID '188981723956'. Notifications to this FCM Token will not be delivered over APNS.Be sure to re-retrieve the FCM token once the APNS device token is set.
2021-11-03 12:45:17.626397+0200 BlueGate[5806:119147] 8.7.0 - [Firebase/Analytics][I-ACS800023] No pending snapshot to activate. SDK name: app_measurement
2021-11-03 12:45:17.735262+0200 BlueGate[5806:119147] 8.7.0 - [Firebase/Analytics][I-ACS023012] Analytics collection enabled

My environment Xcode 12.5.1

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 iOS?

Appreciate any comments or help.

Daniel
  • 11
  • 2
  • If I remove UIWindowSceneSessionRoleApplication from Info.plist nothing changes – Daniel Nov 03 '21 at 11:18
  • It's not really clear what the problem is. "On launching on simulator CarPlay launches good" / "on iPhone Simulator it's not launched": Do you mean your CarPlay app launches when starting the CarPlay simulator via I/O-External Displays-CarPlay... but your iOS app is NOT launching anymore since your changes? – fruitcoder Nov 10 '21 at 09:51

1 Answers1

0

The keys of your application scene in the plist seem to be wrong. Try using UISceneConfigurationName instead of Configuration Name, UISceneDelegateClassName instead of Delegate Class Name and UILaunchStoryboardName instead of Storyboard Name.

fruitcoder
  • 1,073
  • 8
  • 24