Lifecycle of a tvOS 13.2 TopShelf extension?

So recently I migrated the topshelf extension for my app from the deprecated TVServiceProvider to the new TVContentProvider in 13.0 and onwards.


I finally got it working (not helped by wasting hours figuring out that the NSExtensionPrincipalClass has to be the first thing listed in the NSExtension dictionary in the Info.plist or the extension just terminates, I kid you not!) but there is one last thing that I can't figure out.


What works:


1. remove any instance of my application from the Apple TV

2. install and launch my app from xcode on the Apple TV

3. when i back out of the app, the topshelf code is working, it calls the loadTopShelfContentWithCompletionHandler function and I am able to give it what it wants and it gets displayed correctly


Problem is, if I terminate the application from Xcode, I can no longer get the topshelf to work when I try and launch it again from Xcode. It is not listed as running (as a process to attach to, for example). The app runs fine, but there is no extension process launched alongside it.


I can get it working again in one of two ways; either A) reboot the Apple TV, in which case I find tvOS launches the extension a few seconds after boot without me doing anything (not even highlighting my app), or, B) following the steps above if I delete the instance from the Apple TV and install it again using Xcode.


Essentially, it behaves as if the top shelf extension is launched once, and only once, on bootup of the Apple TV, or on first install. It appears to get terminated when I launch the app again using xcode (e.g. with a new build or something, or even running the same build) and only A) or B) above can get it running again.


Has anyone else seen this?

Replies

Just to add, I get the same behaviour from the Apple example project:


https://developer.apple.com/documentation/tvservices/building_a_full_screen_top_shelf_extension?language=objc


I also forgot to mention this is with Xcode 11.2.1.

I also have the same problem 😟 Any solution?

In tvOS 14.+ I experienced a similarly undesired behavior. When I launched the TopShelf extension in the tvOS Simulator, using TopShelf as the Run Target, everything went fine all the time.

When TestFlight users installed the app with the newly included TopShelf extension, the TopShelf did not load. Only after a power cycle, the TopShelf Items showed up.

How is that feature supposed to work for apps which provide a TopShelf extension only as a later addition? Will the users honestly have to pull the power plug before they can see it?
Same here. When I debug the Extension with TopShelf as the Run Target, I see the top shelf, but cannot "wait for app to launch" and attach to debug the cold start scenario. When I chose to run the app without building, it is build nevertheless and the top shelf extension is not loading anymore.