从 Xcode 12.5.1 CarPlay 模拟器启动时,CarPlay 停车应用程序崩溃
Posted
技术标签:
【中文标题】从 Xcode 12.5.1 CarPlay 模拟器启动时,CarPlay 停车应用程序崩溃【英文标题】:CarPlay parking app crashed when launching from Xcode 12.5.1 CarPlay simulator 【发布时间】:2021-11-03 11:13:37 【问题描述】:我是 ios 开发的新手。有任务通过 CarPlay 扩展我们的 iOS 应用程序。我创建了“CarPlaySceneDelegate”类作为 Car Play 的入口点。代码如下:
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
我在 Info.plist 中添加了这个配置:
<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>
在模拟器上启动时,CarPlay 根据 CarPlaySceneDelegate 类启动良好。但是在 iPhone Simulator 上它根本没有启动。应用加载和屏幕变黑。
在控制台中:
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
我的环境 Xcode 12.5.1
我做错了什么还是有什么其他方法可以通过 Xcode/swift 实现 CarPlay 部分功能,同时将移动应用程序保留在 iOS 上?
感谢任何 cmets 或帮助。
【问题讨论】:
如果我从 Info.plist 中删除 UIWindowSceneSessionRoleApplication 没有任何变化 问题出在哪里还不是很清楚。 “在模拟器上启动 CarPlay 启动良好”/“在 iPhone 模拟器上它没有启动”:您的意思是您的 CarPlay 应用程序在通过 I/O-External Displays-CarPlay 启动 CarPlay 模拟器时启动......但是您的 iOS 应用程序没有启动自从你做出改变后就不再了吗? 【参考方案1】:你的应用场景在plist中的key好像不对。尝试使用UISceneConfigurationName
代替Configuration Name
、UISceneDelegateClassName
代替Delegate Class Name
和UILaunchStoryboardName
代替Storyboard Name
。
【讨论】:
以上是关于从 Xcode 12.5.1 CarPlay 模拟器启动时,CarPlay 停车应用程序崩溃的主要内容,如果未能解决你的问题,请参考以下文章
将 CarPlay 模拟器添加到我的 React Native 应用程序
无法使用 Flutter 1.22 在我的 XCODE 12.5.1 上启动我的应用程序