mono / SkiaSharp

SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
MIT License
4.38k stars 535 forks source link

[BUG] Cannot build or run .Net 8 tvOS project #2947

Open munit79 opened 1 month ago

munit79 commented 1 month ago

Description

Create a new tvOS application in .Net 8, it builds and works fine. If I add a SkiaSharp reference, i.e.

<PackageReference Include="SkiaSharp" Version="2.88.8" />

Then the build fails with this error...

  ld: building for tvOS Simulator, but linking in dylib built for tvOS, file '/Users/mt/.nuget/packages/skiasharp.nativeassets.tvos/2.88.8/runtimes/tvos/native/libSkiaSharp.framework/libSkiaSharp' for architecture arm64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : clang++ exited with code 1: [/Users/mt/Desktop/test/test.csproj]
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : ld: building for tvOS Simulator, but linking in dylib built for tvOS, file '/Users/mt/.nuget/packages/skiasharp.nativeassets.tvos/2.88.8/runtimes/tvos/native/libSkiaSharp.framework/libSkiaSharp' for architecture arm64 [/Users/mt/Desktop/test/test.csproj]
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : clang: error: linker command failed with exit code 1 (use -v to see invocation) [/Users/mt/Desktop/test/test.csproj]

Build FAILED.

/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1836,3): warning : The file '/Users/mt/.nuget/packages/skiasharp.nativeassets.tvos/2.88.8/runtimes/tvos/native/.DS_Store' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle. [/Users/mt/Desktop/test/test.csproj]
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : clang++ exited with code 1: [/Users/mt/Desktop/test/test.csproj]
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : ld: building for tvOS Simulator, but linking in dylib built for tvOS, file '/Users/mt/.nuget/packages/skiasharp.nativeassets.tvos/2.88.8/runtimes/tvos/native/libSkiaSharp.framework/libSkiaSharp' for architecture arm64 [/Users/mt/Desktop/test/test.csproj]
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : clang: error: linker command failed with exit code 1 (use -v to see invocation) [/Users/mt/Desktop/test/test.csproj]

Code

https://github.com/munit79/tvosfail

Expected Behavior

I'd expect the app to build and run.

Actual Behavior

It seems to want to link the wrong version of SkiaSharp, i.e. the device build rather than a simulator build.

I get a similar problem when compiling for the App Store, it builds OK, but Apple rejects the build because the skiasharp library is built for the simulator, not the device.

We were able to use SkiaSharp successfully on our Xamarin version of the tvOS app, and we can also successfully use it on the MAUI based iOS version of the app.

Version of SkiaSharp

2.88.3 (Current)

Last Known Good Version of SkiaSharp

Other (Please indicate in the description)

IDE / Editor

Visual Studio Code (macOS)

Platform / Operating System

macOS

Platform / Operating System Version

Building on MacBook Pro M3 Max

Devices

No response

Relevant Screenshots

No response

Relevant Log Output

mt@MacBook-Pro-M3 test % dotnet build -t:Run -f net8.0-tvos
  Determining projects to restore...
  All projects are up-to-date for restore.
  Detected signing identity:

    Bundle Id: com.companyname.test
    App Id: com.companyname.test
  test -> /Users/mt/Desktop/test/bin/Debug/net8.0-tvos/tvossimulator-arm64/test.dll
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1836,3): warning : The file '/Users/mt/.nuget/packages/skiasharp.nativeassets.tvos/2.88.8/runtimes/tvos/native/.DS_Store' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle. [/Users/mt/Desktop/test/test.csproj]
  Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
  Tool xcrun execution finished (exit code = 1).

  ld: building for tvOS Simulator, but linking in dylib built for tvOS, file '/Users/mt/.nuget/packages/skiasharp.nativeassets.tvos/2.88.8/runtimes/tvos/native/libSkiaSharp.framework/libSkiaSharp' for architecture arm64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : clang++ exited with code 1: [/Users/mt/Desktop/test/test.csproj]
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : ld: building for tvOS Simulator, but linking in dylib built for tvOS, file '/Users/mt/.nuget/packages/skiasharp.nativeassets.tvos/2.88.8/runtimes/tvos/native/libSkiaSharp.framework/libSkiaSharp' for architecture arm64 [/Users/mt/Desktop/test/test.csproj]
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : clang: error: linker command failed with exit code 1 (use -v to see invocation) [/Users/mt/Desktop/test/test.csproj]

Build FAILED.

/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1836,3): warning : The file '/Users/mt/.nuget/packages/skiasharp.nativeassets.tvos/2.88.8/runtimes/tvos/native/.DS_Store' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle. [/Users/mt/Desktop/test/test.csproj]
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : clang++ exited with code 1: [/Users/mt/Desktop/test/test.csproj]
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : ld: building for tvOS Simulator, but linking in dylib built for tvOS, file '/Users/mt/.nuget/packages/skiasharp.nativeassets.tvos/2.88.8/runtimes/tvos/native/libSkiaSharp.framework/libSkiaSharp' for architecture arm64 [/Users/mt/Desktop/test/test.csproj]
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : clang: error: linker command failed with exit code 1 (use -v to see invocation) [/Users/mt/Desktop/test/test.csproj]
    1 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.77
mt@MacBook-Pro-M3 test % dotnet build -t:Run -f net8.0-tvos
  Determining projects to restore...
/Users/mt/Desktop/test/test.csproj : warning NU1903: Package 'SkiaSharp' 2.88.3 has a known high severity vulnerability, https://github.com/advisories/GHSA-j7hp-h8jx-5ppr [/Users/mt/Desktop/test/test.sln]
  All projects are up-to-date for restore.
  Detected signing identity:

    Bundle Id: com.companyname.test
    App Id: com.companyname.test
/Users/mt/Desktop/test/test.csproj : warning NU1903: Package 'SkiaSharp' 2.88.3 has a known high severity vulnerability, https://github.com/advisories/GHSA-j7hp-h8jx-5ppr
  test -> /Users/mt/Desktop/test/bin/Debug/net8.0-tvos/tvossimulator-arm64/test.dll
  Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
  Optimizing assemblies for size. This process might take a while.
  Tool xcrun execution finished (exit code = 1).

  ld: building for tvOS Simulator, but linking in dylib built for tvOS, file '/Users/mt/.nuget/packages/skiasharp.nativeassets.tvos/2.88.3/runtimes/tvos/native/libSkiaSharp.framework/libSkiaSharp' for architecture arm64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)

/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : clang++ exited with code 1: [/Users/mt/Desktop/test/test.csproj]
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : ld: building for tvOS Simulator, but linking in dylib built for tvOS, file '/Users/mt/.nuget/packages/skiasharp.nativeassets.tvos/2.88.3/runtimes/tvos/native/libSkiaSharp.framework/libSkiaSharp' for architecture arm64 [/Users/mt/Desktop/test/test.csproj]
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : clang: error: linker command failed with exit code 1 (use -v to see invocation) [/Users/mt/Desktop/test/test.csproj]

Build FAILED.

/Users/mt/Desktop/test/test.csproj : warning NU1903: Package 'SkiaSharp' 2.88.3 has a known high severity vulnerability, https://github.com/advisories/GHSA-j7hp-h8jx-5ppr
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : clang++ exited with code 1: [/Users/mt/Desktop/test/test.csproj]
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : ld: building for tvOS Simulator, but linking in dylib built for tvOS, file '/Users/mt/.nuget/packages/skiasharp.nativeassets.tvos/2.88.3/runtimes/tvos/native/libSkiaSharp.framework/libSkiaSharp' for architecture arm64 [/Users/mt/Desktop/test/test.csproj]
/usr/local/share/dotnet/packs/Microsoft.tvOS.Sdk/17.2.8078/targets/Xamarin.Shared.Sdk.targets(1564,3): error : clang: error: linker command failed with exit code 1 (use -v to see invocation) [/Users/mt/Desktop/test/test.csproj]
    1 Warning(s)
    1 Error(s)

Time Elapsed 00:00:22.45
mt@MacBook-Pro-M3 test %

Code of Conduct

mattleibow commented 1 month ago

I suspect it will need something like this: https://github.com/mono/SkiaSharp/pull/2468

munit79 commented 1 month ago

@mattleibow Is there a timeframe for this fix? Since Xamarin won't support the later Apple SDKs, we're forced to move to .Net 8, and Skia is a major part of our app.