xamarin / xamarin-macios

.NET for iOS, Mac Catalyst, macOS, and tvOS provide open-source bindings of the Apple SDKs for use with .NET managed languages such as C#
Other
2.44k stars 509 forks source link

Exception When Using tvOS TVTopShelfContentProvider #13260

Open jonedmiston opened 2 years ago

jonedmiston commented 2 years ago

With tvOS version 13+ Apple releases new Top Shelf capabilities (display in full screen, etc) and deprecated many of the existing Top Shelf classes. When creating a new tvOS app in Xamarin it's still using the older deprecated way. In trying to use the new classes I've run into an exception show below.

image

This appears to be address in the Stack Overflow article.

Updating the value in the Info.plist is trivial, but I don't see a way to update the productType from com.apple.product-type.tv-app-extension to com.apple.product-type.app-extension.

I have a working sample in XCode that when I change the productType back to the old value generates the same exception (show below).

image

It seems to me then all I need to do is know how to change the productType value in Xamarin and I should be set.

Any thoughts on how to change this value?

Steps to Reproduce

  1. Create a new Xamarin tvOS app
  2. Add a Service Extension for Top Shelf
  3. Update the provided code to use TVTopShelfContentProvider (my humble initial stab is below, note it's untested due to the issue above).

Expected Behavior

Would be able to use the new TVTopShelfContentProvider provided in tvOS 13.

Actual Behavior

Limited to using deprecated older style Top Shelf.

Environment

=== Visual Studio Community 2019 for Mac ===

Version 8.10.11 (build 8)
Installation UUID: 47de0b69-af5c-403d-9eab-1cc35abcba5f
                GTK+ 2.24.23 (Raleigh theme)
                Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

                Package version: 612000140

=== Mono Framework MDK ===

Runtime:
                Mono 6.12.0.140 (2020-02/51d876a041e) (64-bit)
                Package version: 612000140

=== Roslyn (Language Service) ===

3.10.0-4.21269.26+029847714208ebe49668667c60ea5b0a294e0fcb

=== Xamarin Designer ===

Version: 16.10.0.119
Hash: 36a2d986f
Branch: remotes/origin/d16-10
Build date: 2021-06-02 19:41:34 UTC

=== NuGet ===

Version: 5.9.0.7134

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/5.0.402/Sdks
SDK Versions:
                5.0.402
                3.1.414
MSBuild SDKs: /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
                5.0.11
                3.1.20

=== .NET Core 3.1 SDK ===

SDK: 3.1.414

=== Xamarin.Profiler ===

Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Apple Developer Tools ===

Xcode 13.1 (19466)
Build 13A1030d

=== Xamarin.Mac ===

Version: 7.14.0.27 (Visual Studio Community)
Hash: 2566861a9
Branch: d16-10
Build date: 2021-07-27 02:34:12-0400

=== Xamarin.iOS ===

Version: 15.0.0.6 (Visual Studio Community)
Hash: 2771277e0
Branch: xcode13-ios
Build date: 2021-09-23 10:36:08-0400

=== Xamarin.Android ===

Version: 11.3.0.4 (Visual Studio Community)
Commit: xamarin-android/d16-10/ae14caf
Android SDK: /Users/jonedmiston/Library/Developer/Xamarin/android-sdk-macosx
                Supported Android versions:
                                None installed

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 30.0.4
SDK Build Tools Version: 30.0.2

Build Information: 
Mono: b4a3858
Java.Interop: xamarin/java.interop/d16-10@f39db25
ProGuard: Guardsquare/proguard/v7.0.1@912d149
SQLite: xamarin/sqlite/3.35.4@85460d3
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-10@c5732a0

=== Microsoft OpenJDK for Mobile ===

Java SDK: /Users/jonedmiston/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.10.0.13
Hash: 1b81df5
Branch: remotes/origin/d16-10
Build date: 2021-09-21 02:30:50 UTC

=== Android Device Manager ===

Version: 16.10.0.15
Hash: 89dcc0b
Branch: remotes/origin/d16-10
Build date: 2021-09-21 02:31:08 UTC

=== Build Information ===

Release ID: 810110008
Git revision: 5467245e1f99a0c8ccdd2acea02d16c3fb65c220
Build date: 2021-10-07 10:49:46-04
Build branch: release-8.10

=== Operating System ===

Mac OS X 10.16.0
Darwin 20.6.0 Darwin Kernel Version 20.6.0
    Mon Aug 30 06:12:20 PDT 2021
    root:xnu-7195.141.6~3/RELEASE_ARM64_T8101 x86_64

Build Logs

Building TopShelfExperimental (Debug|iPhoneSimulator)
Build started 11/3/2021 1:29:24 PM.
__________________________________________________
Project "/Users/jonedmiston/Projects/TopShelfExperimental/TopShelf/TopShelf.csproj" (Build target(s)):

Target _DetectDebugNetworkConfiguration:
      DebugIPAddresses: 127.0.0.1
Target _BeforeCoreCompileImageAssets:
  Skipping target "_BeforeCoreCompileImageAssets" because all output files are up-to-date with respect to the input files.
Target _DetectSigningIdentity:
    Detected signing identity:

      Bundle Id: com.companyname.TopShelfExperimental.TopShelf
      App Id: com.companyname.TopShelfExperimental.TopShelf
Target _CoreCompileImageAssets:
  Skipping target "_CoreCompileImageAssets" because all output files are up-to-date with respect to the input files.
Target _BeforeCoreCompileInterfaceDefinitions:
  Skipping target "_BeforeCoreCompileInterfaceDefinitions" because it has no inputs.
Target _BeforeCoreCompileInterfaceDefinitions:
  Skipping target "_BeforeCoreCompileInterfaceDefinitions" because it has no inputs.
Target _BeforeCoreCompileInterfaceDefinitions:
  Skipping target "_BeforeCoreCompileInterfaceDefinitions" because it has no inputs.
Target _CoreCompileInterfaceDefinitions:
  Skipping target "_CoreCompileInterfaceDefinitions" because it has no inputs.
Target _BeforeCoreCompileSceneKitAssets:
  Skipping target "_BeforeCoreCompileSceneKitAssets" because it has no inputs.
Target _BeforeCoreCompileSceneKitAssets:
  Skipping target "_BeforeCoreCompileSceneKitAssets" because it has no inputs.
Target _BeforeCoreCompileSceneKitAssets:
  Skipping target "_BeforeCoreCompileSceneKitAssets" because it has no inputs.
Target _CoreCompileSceneKitAssets:
  Skipping target "_CoreCompileSceneKitAssets" because it has no inputs.
Target _CoreCompileColladaAssets:
  Skipping target "_CoreCompileColladaAssets" because it has no inputs.
Target _BeforeCompileTextureAtlases:
  Skipping target "_BeforeCompileTextureAtlases" because it has no inputs.
Target _BeforeCompileTextureAtlases:
  Skipping target "_BeforeCompileTextureAtlases" because it has no inputs.
Target _BeforeCompileTextureAtlases:
  Skipping target "_BeforeCompileTextureAtlases" because it has no inputs.
Target _CoreCompileTextureAtlases:
  Skipping target "_CoreCompileTextureAtlases" because it has no inputs.
Target _BeforeCompileCoreMLModels:
  Skipping target "_BeforeCompileCoreMLModels" because all output files are up-to-date with respect to the input files.
Target _CoreCompileCoreMLModels:
  Skipping target "_CoreCompileCoreMLModels" because all output files are up-to-date with respect to the input files.
Target _CoreOptimizePngImages:
  Skipping target "_CoreOptimizePngImages" because it has no outputs.
Target _CoreOptimizePropertyLists:
  Skipping target "_CoreOptimizePropertyLists" because it has no inputs.
Target _CoreOptimizeLocalizationFiles:
  Skipping target "_CoreOptimizeLocalizationFiles" because it has no inputs.
Target GenerateTargetFrameworkMonikerAttribute:
  Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
Target CoreCompile:
    /Applications/Visual Studio.app/Contents/Resources/lib/monodevelop/bin/MSBuild/Current/bin/Roslyn/csc.exe /noconfig /nowarn:2008 /fullpaths /nostdlib+ /errorreport:prompt /warn:4 /define:__TVOS__;__MOBILE__;__UNIFIED__;DEBUG /errorendlocation /preferreduilang:en-US /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.TVOS/mscorlib.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.TVOS/System.Core.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.TVOS/System.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.TVOS/Facades/System.Drawing.Common.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.TVOS/System.Xml.dll /reference:/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.TVOS/Xamarin.TVOS.dll /debug+ /debug:full /optimize- /out:obj/iPhoneSimulator/Debug/TopShelf.dll /target:library /utf8output /langversion:7.3 ServiceProvider.cs "obj/iPhoneSimulator/Debug/Xamarin.TVOS,Version=v1.0.AssemblyAttributes.cs"
    CompilerServer: server - server processed compilation - 1e15ee9a-c0af-4ce2-bdc0-a3741a632b7a
Target CopyFilesToOutputDirectory:
    Copying file from "/Users/jonedmiston/Projects/TopShelfExperimental/TopShelf/obj/iPhoneSimulator/Debug/TopShelf.dll" to "/Users/jonedmiston/Projects/TopShelfExperimental/TopShelf/bin/iPhoneSimulator/Debug/TopShelf.dll".
    TopShelf -> /Users/jonedmiston/Projects/TopShelfExperimental/TopShelf/bin/iPhoneSimulator/Debug/TopShelf.dll
    Copying file from "/Users/jonedmiston/Projects/TopShelfExperimental/TopShelf/obj/iPhoneSimulator/Debug/TopShelf.pdb" to "/Users/jonedmiston/Projects/TopShelfExperimental/TopShelf/bin/iPhoneSimulator/Debug/TopShelf.pdb".
Target _CopyResourcesToBundle:
  Skipping target "_CopyResourcesToBundle" because it has no outputs.
Target _CopyResourcesToBundle:
  Skipping target "_CopyResourcesToBundle" because it has no outputs.
Target _WriteAppManifest:
  Skipping target "_WriteAppManifest" because all output files are up-to-date with respect to the input files.
Target _CompileToNative:
    /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch "@/Users/jonedmiston/Projects/TopShelfExperimental/TopShelf/obj/iPhoneSimulator/Debug/device-builds/apple tv 4k (at 1080p) (2nd generation)-15.0/response-file.rsp" 
    Xamarin.iOS 15.0.0.6 (xcode13-ios: 2771277e0) using framework: /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator15.0.sdk
    Touching "bin/iPhoneSimulator/Debug/device-builds/apple tv 4k (at 1080p) (2nd generation)-15.0/bundler.stamp".
Target _CopyResourcesToBundle:
  Skipping target "_CopyResourcesToBundle" because it has no outputs.
Target _CopyResourcesToBundle:
  Skipping target "_CopyResourcesToBundle" because it has no outputs.
Target _CopyAppExtensionsToBundle:
  Skipping target "_CopyAppExtensionsToBundle" because it has no inputs.
Target _CollectFrameworks:
    No Frameworks directory found.

__________________________________________________
Project "/Users/jonedmiston/Projects/TopShelfExperimental/TopShelfExperimental/TopShelfExperimental.csproj" (Build target(s)):

Target _DetectDebugNetworkConfiguration:
      DebugIPAddresses: 127.0.0.1
Target _BeforeCoreCompileImageAssets:
  Skipping target "_BeforeCoreCompileImageAssets" because all output files are up-to-date with respect to the input files.
Target _DetectSigningIdentity:
    Detected signing identity:

      Bundle Id: com.companyname.TopShelfExperimental
      App Id: com.companyname.TopShelfExperimental
Target _CoreCompileImageAssets:
  Skipping target "_CoreCompileImageAssets" because all output files are up-to-date with respect to the input files.
Target _BeforeCoreCompileInterfaceDefinitions:
  Skipping target "_BeforeCoreCompileInterfaceDefinitions" because all output files are up-to-date with respect to the input files.
Target _CoreCompileInterfaceDefinitions:
  Skipping target "_CoreCompileInterfaceDefinitions" because all output files are up-to-date with respect to the input files.
Target _BeforeCoreCompileSceneKitAssets:
  Skipping target "_BeforeCoreCompileSceneKitAssets" because it has no inputs.
Target _BeforeCoreCompileSceneKitAssets:
  Skipping target "_BeforeCoreCompileSceneKitAssets" because it has no inputs.
Target _BeforeCoreCompileSceneKitAssets:
  Skipping target "_BeforeCoreCompileSceneKitAssets" because it has no inputs.
Target _CoreCompileSceneKitAssets:
  Skipping target "_CoreCompileSceneKitAssets" because it has no inputs.
Target _CoreCompileColladaAssets:
  Skipping target "_CoreCompileColladaAssets" because it has no inputs.
Target _BeforeCompileTextureAtlases:
  Skipping target "_BeforeCompileTextureAtlases" because it has no inputs.
Target _BeforeCompileTextureAtlases:
  Skipping target "_BeforeCompileTextureAtlases" because it has no inputs.
Target _BeforeCompileTextureAtlases:
  Skipping target "_BeforeCompileTextureAtlases" because it has no inputs.
Target _CoreCompileTextureAtlases:
  Skipping target "_CoreCompileTextureAtlases" because it has no inputs.
Target _BeforeCompileCoreMLModels:
  Skipping target "_BeforeCompileCoreMLModels" because all output files are up-to-date with respect to the input files.
Target _CoreCompileCoreMLModels:
  Skipping target "_CoreCompileCoreMLModels" because all output files are up-to-date with respect to the input files.
Target _CoreOptimizePngImages:
  Skipping target "_CoreOptimizePngImages" because it has no outputs.
Target _CoreOptimizePropertyLists:
  Skipping target "_CoreOptimizePropertyLists" because it has no inputs.
Target _CoreOptimizeLocalizationFiles:
  Skipping target "_CoreOptimizeLocalizationFiles" because it has no inputs.
Target GenerateTargetFrameworkMonikerAttribute:
  Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
Target CoreCompile:
  Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
Target CopyFilesToOutputDirectory:
    TopShelfExperimental -> /Users/jonedmiston/Projects/TopShelfExperimental/TopShelfExperimental/bin/iPhoneSimulator/Debug/TopShelfExperimental.exe
Target _CopyResourcesToBundle:
  Skipping target "_CopyResourcesToBundle" because all output files are up-to-date with respect to the input files.
Target _WriteAppManifest:
  Skipping target "_WriteAppManifest" because all output files are up-to-date with respect to the input files.
Target _ResolveAppExtensionReferences:
    __________________________________________________
    Project "/Users/jonedmiston/Projects/TopShelfExperimental/TopShelfExperimental/TopShelfExperimental.csproj" is building "/Users/jonedmiston/Projects/TopShelfExperimental/TopShelf/TopShelf.csproj" (GetBundleTargetPath target(s)):

Target _CompileToNative:
    /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/bin/mtouch "@/Users/jonedmiston/Projects/TopShelfExperimental/TopShelfExperimental/obj/iPhoneSimulator/Debug/device-builds/apple tv 4k (at 1080p) (2nd generation)-15.0/response-file.rsp" 
    Xamarin.iOS 15.0.0.6 (xcode13-ios: 2771277e0) using framework: /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator15.0.sdk
    Cached assemblies reloaded.
    /Users/jonedmiston/Projects/TopShelfExperimental/TopShelfExperimental/bin/iPhoneSimulator/Debug/device-builds/apple tv 4k (at 1080p) (2nd generation)-15.0/TopShelfExperimental.app built successfully.
    /Users/jonedmiston/Projects/TopShelfExperimental/TopShelf/bin/iPhoneSimulator/Debug/device-builds/apple tv 4k (at 1080p) (2nd generation)-15.0/TopShelf.appex built successfully.
    Touching "bin/iPhoneSimulator/Debug/device-builds/apple tv 4k (at 1080p) (2nd generation)-15.0/bundler.stamp".
Target _CopyAppExtensionsToBundle:
    /usr/bin/ditto "/Users/jonedmiston/Projects/TopShelfExperimental/TopShelf/bin/iPhoneSimulator/Debug/device-builds/apple tv 4k (at 1080p) (2nd generation)-15.0/TopShelf.appex" "bin/iPhoneSimulator/Debug/device-builds/apple tv 4k (at 1080p) (2nd generation)-15.0/TopShelfExperimental.app/PlugIns/TopShelf.appex" 
    Directory "bin/iPhoneSimulator/Debug/device-builds/apple tv 4k (at 1080p) (2nd generation)-15.0/TopShelfExperimental.app/PlugIns/TopShelf.appex/_CodeSignature" doesn't exist. Skipping.
    Directory "bin/iPhoneSimulator/Debug/device-builds/apple tv 4k (at 1080p) (2nd generation)-15.0/TopShelfExperimental.app/../TopShelf.appex.dSYM" doesn't exist. Skipping.
Target _ValidateAppBundle:
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(555,3): warning : The App Extension 'TopShelf' has an unrecognized NSExtensionPointIdentifier value ('com.apple.tv-top-shelf').
    /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(555,3): warning :         
Done building target "_ValidateAppBundle" in project "TopShelfExperimental.csproj".
Target _CodesignFrameworks:
  Skipping target "_CodesignFrameworks" because all output files are up-to-date with respect to the input files.

Done building project "TopShelfExperimental.csproj".

Build succeeded.

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(555,3): warning : The App Extension 'TopShelf' has an unrecognized NSExtensionPointIdentifier value ('com.apple.tv-top-shelf').
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(555,3): warning :         
    1 Warning(s)
    0 Error(s)

Time Elapsed 00:00:07.42

========== Build: 2 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

Build: 0 errors, 1 warning

Example Project (If Possible)

Here's a link to my humble test app. Link to download.

chamons commented 2 years ago

I can verify the current extension template uses the deprecated API and your ported version does not current work. I will look more into it shortly.

rachelkang commented 2 years ago

As an update, I've been looking into this issue with @chamons and was able to reproduce the issue on this Xamarin.iOS project which is close to this Xcode project that does not show the issue.

After comparing the two projects, one theory we have come to is that the issue might be related to code signing. This requires that we create a provisioning profile, which requires having access to a physical Apple TV device - once we gain access to one, we will resume this investigation.

In the meantime, if anyone has further insights, please feel free to share.

jonedmiston commented 2 years ago

@rachelkang thank you for looking into this. We appreciate your work!

From the this StackOverflow (https://stackoverflow.com/questions/58504864/tvos-13-top-shelf-nsextensionprincipalclass-product-module-name-contentprovid) it looks like we just need to update the productType from com.apple.product-type.tv-app-extension to com.apple.product-type.app-extension.

We confirmed switching that setting back and forth on an Xcode project produced the anticipated results. We just don't see how to change that setting in Xamarin.

Not sure if that helps...?

chamons commented 2 years ago

From what we can tell, that is an internal "project type" for Xcode projects, and something specific to their format. How that actually changes the build and what changes Xamarin.iOS would need to support it will unfortunately require some research.

jonedmiston commented 1 year ago

Any update on this? Is TvOS still something that will be supported in Xamarin going forward?

rolfbjarne commented 1 year ago

@jonedmiston yes, we still support tvOS, but we haven't had time to look at this particular issue yet.

Noemata commented 1 year ago

All this is getting too long in the tooth. With the confusion injected into the mix by the MAUI emphasis over all things Xamarin and UWP, it's very hard to tell where Microsoft is headed and why. MAUI did claim tvOS support, but as is now typical, that was a premature announcement. I've been peppering some of these forums with the hope that folks at Microsoft will wake up to their predicament, which is looming irrelevancy. I personally have been switching over to Apple tech. Life has suddenly started to resemble the good old days of Microsoft.