今天在有限的设备上扩展 "Unable to Load"

Today Extension "Unable to Load" on limited devices

我有一个带有 Today Extension 的 iOS 应用程序。我们现在正在进行测试 (TestFlight),并且已经在大约十台设备上进行了测试。关联的小部件在所有这些设备上都可以正常显示,但其中一个设备除外。在一台设备上,Widget 会显示可怕的 "Unable to Load" 消息。我们已尝试重启设备、deleting/reinstalling 应用等

查看设备日志,我看到这是第一个麻烦的参考:

container: WGMajorListViewController> Unable to load widget view controller with service (com.mycompany.MyApp.myApp-Today-Extension): Couldn\M-b\M^@\M^Yt communicate with a helper application.
container: WGMajorListViewController> No longer waiting on connection semaphore (<OS_dispatch_semaphore: 0x174c85410>)
container: WGMajorListViewController> Severed remote view controller connection
container: WGMajorListViewController> Widget disconnected unexpectedly
container: WGMajorListViewController> Aborting active life cycle sequence: <WGWidgetLifeCycleSequence: 0x175035460; sequenceID: com.mycompany.MyApp.myApp-Today-Extension.WGMajorListViewController.7/11/17, 3:13:00 PM; currentState: WGWidgetLifeCycleSequenceStateDidRequestRemoteView>
container: WGMajorListViewController> Remote view controller disconnected unexpectedly
container: WGMajorListViewController> Attempting to reconnect to remote view controller

扩展程序的代码没有尝试打开主机应用程序,所以这个错误让我很困惑。也许这是指内部 (iOS) 帮助应用程序?

第一行中的奇数转义字符在日志中。在这些行之后,它再次尝试,可能再尝试两次,然后失败。最终我看到 Can't request remote view controller that is blacklisted 并且设备在重新启动之前不会重试:

mediaserverd(CoreMedia)[27] <Notice>: -CMSessionMgr- cmsmHandleApplicationStateChange: CMSession: Client com.mycompany.MyApp.myApp-Today-Extension with pid '257' is now Terminated. Background entitlement: NO
mediaserverd(CoreMedia)[27] <Notice>: -CMSessionMgr- cmsmHandleApplicationStateChange: CMSession: Client com.mycompany.MyApp.myApp-Today-Extension with pid '259' is now Terminated. Background entitlement: NO
symptomsd(SymptomEvaluator)[121] <Notice>: 257 com.mycompany.MyApp.myApp-Today-Extension: Terminated (most elevated: Terminated)
symptomsd(SymptomEvaluator)[121] <Notice>: 259 com.mycompany.MyApp.myApp-Today-Extension: Terminated (most elevated: Terminated)
symptomsd(SymptomEvaluator)[121] <Notice>: Entry, display name com.mycompany.MyApp.myApp-Today-Extension uuid (null) pid 257 isFront 0
symptomsd(SymptomEvaluator)[121] <Notice>: Duplicate removal of display name com.mycompany.MyApp.myApp-Today-Extension
symptomsd(SymptomEvaluator)[121] <Notice>: Entry, display name com.mycompany.MyApp.myApp-Today-Extension uuid (null) pid 259 isFront 0
symptomsd(SymptomEvaluator)[121] <Notice>: Duplicate removal of display name com.mycompany.MyApp.myApp-Today-Extension
container: WGMajorListViewController> End sequence '(null)' with reason: disappearance transition
container: WGMajorListViewController> Can't end sequence as argument sequence ((null)) doesn't match active sequence ((null)), or there's no active sequence
container: WGMajorListViewController> Begin sequence with reason: appearance transition
container: WGMajorListViewController> Initiating new life cycle sequence: '<WGWidgetLifeCycleSequence: 0x17522b6e0; sequenceID: com.mycompany.MyApp.myApp-Today-Extension.WGMajorListViewController.7/11/17, 3:13:12 PM; currentState: WGWidgetLifeCycleSequenceStateQuiescent>'
container: WGMajorListViewController> Connection requested with reason: 'appearance transition'
container: WGMajorListViewController> Will request remote view controller
container: WGMajorListViewController> Can't request remote view controller that is blacklisted

我没有看到扩展代码本身的任何日志记录,也没有看到它实际启动的任何迹象。

有问题的设备是 iPhone 7 Plus,运行 public 版本的 iOS 10.3.2。该小部件在所有其他设备上运行良好,其中许多也是 10.3.2。 None 其他是 iPhone 7 Plus。该小部件在 iPhone 7 Plus 模拟器中运行良好。

相同的设备可以很好地运行 App Store 版本的小部件,尽管该版本是针对 iOS 9 和 Xcode 7 构建的。新版本使用 10.3 作为 Base SDK,使用 Xcode 8.3.3.

有什么想法吗?

哇,这太奇怪了。问题的根源是一张坏图像,或者更具体地说是坏图像代码(从 PaintCode 导出)。该代码似乎在 "Plus" 大小的设备上给 Widget 的 Storyboard 带来了麻烦,这些设备是 3x。故事板从未初始化。

我使用(并且喜欢)PaintCode,并尽可能使用它的图像代码。一切都是矢量,可以任意大小使用。好东西。无论如何,您可以通过将 PaintCode 代码分配给拖入情节提要中的对象来在情节提要中使用 PaintCode 图像。然后从该对象按住 control 并拖动到同一个 Storyboard 上的 UIImageView。在运行时,无论设备分辨率或图像大小如何,图像都能完美绘制。

Widget的Storyboard有三张图片,全部来自PaintCode。三张图片中的一张导致了问题。如果我删除图像,一切都很好。将其添加回来,Widget 永远不会启动,并显示 "Unable to Load"。图像并不复杂,据我所知很接近。只是一个用 Sketch 绘制的矢量图标。

我不明白为什么这张图片有问题。我玩过 PaintCode 设置,导出了几种方式,没有改变。所以我使用 Sketch 创建了一个 PDF 资产,并为图像使用了典型的资产目录。

查看控制台,我完全看不到任何线索,即使现在回想起来也是如此。我猜测,由于 Swift 代码从未启动,而这只是 "Plus" 大小问题,因此可能存在 Storyboard 问题。一旦我删除了所有 AutoLayout 约束和损坏的 Storyboard 文件,我的直觉就出现了。所以我通过 Widget 故事板重新创建,并沿途进行测试。当我重新添加 PaintCode 图像时它崩溃了。一旦我有了这个,我回到我原来的 Storyboard,拉出有问题的图像,Widget 显示正常。

我将 trim 项目下来并发送一份副本给 PixelCut 的好人,让他们知道。如果他们有解决方法,我会 post 在这里。

还有一次会发生这种情况,那就是如果在 Scheme 目标的 运行 诊断部分下,您已经打开了线程清理器/未定义的行为清理器。它似乎不喜欢这些选项。