无法理解 watchkit 扩展崩溃

Posted

技术标签:

【中文标题】无法理解 watchkit 扩展崩溃【英文标题】:Unable to understand watchkit extension crash 【发布时间】:2018-09-30 15:45:42 【问题描述】:

我从应用程序的用户那里收到了有关 Xcode 管理器的这些崩溃报告。它在崩溃中没有显示我的任何代码行,看起来它在初始化时崩溃了。我不知道如何进行调试。你能帮忙吗:

Thread 0#0  (null) in 0x300000 ()
#1  (null) in 0x300000 ()
#2  (null) in _WKInterfaceControllerCreateClass ()
#3  (null) in __115-[SPRemoteInterface createViewController:className:properties:contextID:info:gestureDescriptions:clientIdentifier:]_block_invoke_3 ()
#4  (null) in __115-[SPRemoteInterface createViewController:className:properties:contextID:info:gestureDescriptions:clientIdentifier:]_block_invoke_2 ()
#5  (null) in spUtils_dispatchAsyncToMainThread ()
#6  (null) in __115-[SPRemoteInterface createViewController:className:properties:contextID:info:gestureDescriptions:clientIdentifier:]_block_invoke ()
#7  (null) in -[SPRemoteInterface performAfterApplicationDidFinishLaunching:] ()
#8  (null) in -[SPRemoteInterface createViewController:className:properties:contextID:info:gestureDescriptions:clientIdentifier:] ()
#9  (null) in __140-[SPExtensionConnection interfaceViewController:createCompanionControllerClass:properties:initializationContextID:info:gestureDescriptions:]_block_invoke ()
#10 (null) in __62-[SPExtensionConnection performOnSendQueue:syncIfUnsuspended:]_block_invoke.583 ()
#11 (null) in spUtils_dispatchAsyncToMainThread ()
#12 (null) in -[SPExtensionConnection performOnSendQueue:syncIfUnsuspended:] ()
#13 (null) in -[SPExtensionConnection interfaceViewController:createCompanionControllerClass:properties:initializationContextID:info:gestureDescriptions:] ()
#14 (null) in -[SPApplicationDelegate interfaceViewController:createCompanionControllerClass:properties:initializationContextID:] ()
#15 (null) in -[SPInterfaceViewController loadView] ()
#16 (null) in -[UIViewController loadViewIfRequired] ()
#17 (null) in -[UIViewController view] ()
#18 (null) in -[SPModalViewController setContentViewController:] ()
#19 (null) in -[SPApplicationDelegate extensionConnection:interfaceViewController:presentViewController:info:initializationContextID:] ()
#20 (null) in -[SPExtensionConnection handlePlistDictionary:] ()
#21 (null) in -[SPExtensionConnection handleProtoPlist:] ()
#22 (null) in __43-[SPExtensionConnection receiveData:reply:]_block_invoke ()
#23 (null) in spUtils_dispatchAsyncToMainThread ()
#24 (null) in -[SPExtensionConnection receiveData:reply:] ()
#25 (null) in -[SPRemoteInterface performForClientConnections:directToUIBlock:] ()
#26 (null) in __54-[SPRemoteInterface sendData:clientIdentifiers:reply:]_block_invoke ()
#27 (null) in spUtils_dispatchAsyncToMainThread ()
#28 (null) in -[SPRemoteInterface sendData:clientIdentifiers:reply:] ()
#29 (null) in -[SPRemoteInterface sendData:clientIdentifiers:] ()
#30 (null) in -[SPRemoteInterface sendPlist:clientIdentifiers:] ()
#31 (null) in -[SPRemoteInterface controller:presentInterfaceController:initializationContextID:] ()
#32 (null) in +[SPRemoteInterface controller:presentInterfaceController:context:] ()
#33 (null) in __59-[WKInterfaceController presentControllerWithName:context:]_block_invoke ()
#34 (null) in -[WKInterfaceController presentControllerWithName:context:] ()

【问题讨论】:

【参考方案1】:

我遇到了类似的问题。就我而言,问题在于我更改了手表应用程序扩展名,因此它不包含下划线字符。在此之后,我经历了这次崩溃。

解决方案是,进入手表应用程序扩展的故事板文件,并在现有视图控制器的身份检查器中,我只是重新输入自定义类名的名称,模块会自动更新。在此之后,它起作用了。希望它也适用于您。

【讨论】:

重新输入可能会导致重新分配目标 - 这可能是修复它的原因。【参考方案2】:

仅供参考。我遇到的问题就是其中一个令人尴尬的问题。

故事板启用了“从目标继承模块”。

但是,Apple 创建的默认布局将可执行文件放在单独的(扩展)目标中。

我需要取消选中该框,并明确引用我的扩展目标。

天啊!

【讨论】:

以上是关于无法理解 watchkit 扩展崩溃的主要内容,如果未能解决你的问题,请参考以下文章

无法在 WatchKit 扩展(CocoaPods)中使用 Parse 库

Xcode+watchkit 模拟:不支持可调试架构:

Watchkit 扩展的嵌套框架问题

在主要目标中包含 pod,而不是在 WatchKit 扩展中

Swift 动态库的 WatchKit 问题

WatchKit 无法从 Pod 导入库