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.48k stars 538 forks source link

[QUESTION] After updating to 2.80.3, I can no longer build for iOS Simulator. #1816

Open tankei-gtj opened 3 years ago

tankei-gtj commented 3 years ago

Hello, after updating to 2.80.3, I can no longer build for iOS Simulator.

Visual Studio for mac said ・linker command failed with exit code 1(use -v to see invocation) ・native linking failed , undefined objective-c class: MTKView. The symbol'_OBJCCLASS$_MTKView' could not be found in any of the libraries of frameworks linked with your application.(MT5211) ・Native linking failed, undefined symbol: _OBJCCLASS$_MTKView. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.(MT5210) ・Native linking failed. Please review the build log and the user flags provided to gcc: -ObjC(MT5201)

I set the mtouch option "--registrar:static" for iOS Simulator. This setting is needed for the binding library used in my project.

Is there a way to solve this problem?

justinimel commented 1 year ago

Im also encountering this issue now. Were you able to solve it?

tankei-gtj commented 1 year ago

Hello, justinimel.

Sorry I haven't solved it yet. I'm still using the 2.80.2 version.

If possible, you may be able to solve it by upgrading Xamarin.iOS.

I don't remember exactly because it happened in the past., If you set "Linker behavior" in "iOS Build" to "Don't Link", You may be able to build for iOS Simulator.

But, I don't know if this is the correct way.

justinimel commented 1 year ago

Seems like the combination of Link SDKs or Link All and using the Static Registrar on the Simulator is the cause of the issue.

Original issue is that older versions of the iOS Simulator didn't support Metal at all, as in it wasn't even included: https://github.com/xamarin/xamarin-macios/issues/4422

Looks like changes were made to the Linker in the Xamarin.Macios project to account for this here: https://github.com/xamarin/xamarin-macios/pull/4510/files#

Starting in 2.80.3 this package brought in support for the Metal API: https://github.com/mono/SkiaSharp/commit/2a87a0d947e69800cdfc8dc31ab38a6a916bf7c1

My suspicion is that the Xamarin changes above aren't 100% correct and bringing in these packages with the Metal Dependencies with the above build settings exposes the issue.

The only solution is to remove the static registrar, but unfortunately I also need it. So i am stuck on the same version as well.

Sadly I'm only using the Forms version and don't even need Metal at all. I've tried various ways to strip that aspect from my builds to allow the linker to work but to no avail.

tankei-gtj commented 1 year ago

Thank you for the detailed information. I also don't need Metal API, so I tried various things at that time, but I couldn't solve it after all. It's been over a year, so I don't remember exactly what I tried.

justinimel commented 1 year ago

I think we're just stuck on this version at this point. It still works for now thankfully.

grahampett commented 1 year ago

I found this could be fixed by adding -gcc_flags '-framework MetalKit' to the Additional MTouch Arguments field in the simulator build configuration