TVTopShelfProvider not initialising

I'm running a near copy of the ServiceProvider class (conforming to the TVTopShelfProvider protocol) from the UIKitCatalog example. However, my ServiceProvider class wont initialise or run at all. It's made using the TV Service Extension by adding a new target, and as far as I can tell all of the build setting, Info.plst, etc are all the same.


I'm checking for initialisation but logging in the init() method and checking the System Log for my log string.


Strange thing is that the UIKitCatalog example ServiceProvider class runs fine and shows up it's items, but mine does not.


I'm running this in the simulator at the moment and am writing in Swift.


Any help with this would be apreciated.

I see this exact thing. I assumed it had to do with the simulator not supporting it. But I hope it starts to, becasue no dev kit is coming my way.

Just checking, do you have TVTopShelfProvider added to your Info.plist, the same way UIKitCatalog does?


NSExtension

> NSExtensionAttributes

>> TVExtensionProtocols

>>> Item 0: TVTopShelfProvider

In my case I have the Info.plist of the TVExtension configured in the right way:



<key>NSExtension</key>

<dict>

<key>NSExtensionAttributes</key>

<dict>

<key>TVExtensionProtocols</key>

<array>

<string>TVTopShelfProvider</string>

</array>

</dict>


and the DevelopmentKit debugger seems to load the TVService, as I can see the APPEX loaded in the AppleTV logs:


Sep 21 07:56:33 Apple-TV installd[45] <Notice>: 0x16e12f000 -[MIInstallableBundle _refreshUUIDForContainer:withError:]: Data container for com.myc.testbed.tv is now at /private/var/mobile/Containers/Data/Application/257E5F73-1439-467B-A2B7-93070A0EB340

Sep 21 07:56:33 Apple-TV installd[45] <Notice>: 0x16e12f000 -[MIInstallableBundle _refreshUUIDForContainer:withError:]: Data container for com.myc.testbed.tv.tvservice is now at /private/var/mobile/Containers/Data/PluginKitPlugin/1831F61C-2FDA-416A-814C-A91C9D0DCBD7

Sep 21 07:56:33 Apple-TV installd[45] <Notice>: 0x16e12f000 -[MIContainer makeContainerLiveReplacingContainer:reason:withError:]: Made container live for com.myc.testbed.tv at /private/var/mobile/Containers/Bundle/Application/281D5AFF-9095-4514-A67F-22B9143EF2AE

Sep 21 07:56:33 Apple-TV installd[45] <Notice>: 0x16e12f000 -[MIInstaller performInstallationWithError:]: Install Successful; Staging: 0.00s; Waiting: 0.00s; Preflight/Patch: 0.08s, Verifying: 0.08s; Overall: 0.27s


But after that I see a lot of warning, and I cannot debug the ServiceProvider, and there is no log at all coming from the extension:


Sep 21 07:56:33 Apple-TV pkd[94] <Warning>: releasing plug-in hold 78C4C0E4-A771-49A7-B3CF-289E45331EEE at client's request

Sep 21 07:56:33 Apple-TV ***[73] <Warning>: LaunchServices: Updating identifier store

Sep 21 07:56:33 Apple-TV pkd[94] <Warning>: INSTALLED:com.myc.testbed.tv.tvservice com.myc.testbed.tv.tvservice(2015180900) <__NSConcreteUUID 0x13c600270> C9CC8A2B-09AB-4175-8CCD-E221671A0565 /private/var/mobile/Containers/Bundle/Application/281D5AFF-9095-4514-A67F-22B9143EF2AE/MyAppTestbedTV.app/PlugIns/MXMTestbedTVService.appex

Sep 21 07:56:33 Apple-TV HeadBoard[103] <Warning>: CUICatalog: Invalid asset name supplied: (null)

Sep 21 07:56:33 Apple-TV HeadBoard[103] <Warning>: CUICatalog: Invalid asset name supplied: (null)

Sep 21 07:56:34 Apple-TV PineBoard[47] <Warning>: [FBSystemService] Error launching : NotFound (4)

Sep 21 07:56:34 Apple-TV PineBoard[47] <Warning>: [FBSystemService] Error launching : NotFound (4)

For me a "TVContentItem"-section with "TVContentItem"-items works fine. Just add the extension, insert a image (e.g. TVSelf.jpg) and paste following code:


var topShelfItems: [TVContentItem] {
    
        guard let tvContentIdentifier = TVContentIdentifier(identifier: "123456789", container: nil) else { fatalError("Error creating content identifier.") }
        guard let tvContentItem = TVContentItem(contentIdentifier: tvContentIdentifier) else { fatalError("Error creating content item.") }
        guard let imageURL = NSBundle.mainBundle().URLForResource("TVSelf", withExtension: "jpg") else { fatalError("Error creating image URL.") }
        tvContentItem.imageURL = imageURL
        tvContentItem.imageShape = .Square
        tvContentItem.displayURL = NSURL(string: "URL")
    
        guard let sectionIdentifier = TVContentIdentifier(identifier: "987654321", container: nil) else { fatalError("Error creating section identifier.") }
        guard let sectiontItem = TVContentItem(contentIdentifier: sectionIdentifier) else { fatalError("Error creating section item.") }
        sectiontItem.title = "Section"
        sectiontItem.topShelfItems = [tvContentItem]
    
        return [sectiontItem]
    }


BTW: You need to define a url-scheme in your info.plist and replace "URL" with it.

I had the same issue with an extension which had been working correclty previously. Nothing I tried worked. So I copied the extension code, deleted the extension completey from the project and then re-created it as a new extension and added in the copied code. It worked fine at that point. So still no idea what actually was wrong but this might be a way to get things working again ...

The NSExtension dictionary also needs an "NSExtensionPointIdentifier" key at the top level specifying the extension point name. The full dictionary should look like:


<dict>
<key>NSExtensionAttributes</key>
<dict>
<key>TVExtensionProtocols</key>
<array>
<string>TVTopShelfProvider</string>
</array>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.tv-services</string>
</dict>

I've done all these things and my projects top shelf extension settings match the "UIKitCatalog" project's extension's settings as far as I can tell but I can only get the top shelf extension to show when I run from the extension's scheme. If I try to run from the tvOS app target's scheme, no top shelf extension shows up. This doesn't seem to be the case for the UIKitCatalog project. If I run from the "UIKitCatalog" target scheme, the top shelf extension shows up fine.


Am I doing something wrong?

TVTopShelfProvider not initialising
 
 
Q