将不建议使用的TVTopShelfProvider
迁移到tvOS分段样式的顶层架子到TVTopShelfContentProvider
,导致启动时出现NSException
。
错误NSExtensionPrincipalClass product_module_name.ContentProvider must implement at least one public protocol
表明我的课程ContentProvider
必须使用协议。 TVTopShelfContentProvider是类,但不是协议。
通过查看Apple的example project,您可以看到它们也仅是TVTopShelfContentProvider
的子类。
最小示例:
class ContentProvider: TVTopShelfContentProvider {
override func loadTopShelfContent(completionHandler: @escaping (TVTopShelfContent?) -> Void) {
requestMediaItemsIfNeeded {
let itemCollection: TVTopShelfItemCollection = TVTopShelfItemCollection(items: self.items)
itemCollection.title = "Collection Title"
let sectionedContent: TVTopShelfSectionedContent = TVTopShelfSectionedContent(sections: [itemCollection])
completionHandler(sectionedContent)
}
}
}
与顶层货架相关的Info.plist值:
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.tv-top-shelf</string>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).ContentProvider</string>
</dict>
我是否缺少需要添加/更新的项目配置值?创建了一个新的最小上层扩展,这些看起来是唯一需要的更改。
我能够通过删除“顶层架子”扩展目标,配置和构建方案,然后重新创建“顶层架子”扩展目标来解决此问题。
这显然是一个极端的解决方案。不幸的是,仍然不清楚确切的问题是什么。我怀疑在创建新的Top Shelf扩展并将其添加到父目标时,Apple会在后台做一些魔术。查看差异不会暴露任何可能的问题。