Add support for ios binary.
s3743761 opened this issue · comments
I tried using a built .a of libheif and that is causing an error and it is not being picked. I filed the issue in xamarin-macios repo and got the following response.
The response indicates that you are building libheif as a statically-linked library, and it need to be a dynamically-linked library (.dylib?) for .NET to be able to call it.
The missing method errors are probably due to your libheif version being too old, libheif-sharp expects libheif version 1.16.2.
Or there is another issue with the AOT compilation that I am not aware of.
I think we can use the static lib using "iOS binding projects" and link that to the project (as I have done in the sample repo). I am unaware of the case to link ".dylib" instead of a ".a".
Do you reckon the dynamic build (dylib) will work with the existing implementation (i.e. without the __)?
I can check for the version of the built libheif.
Do you reckon the dynamic build (dylib) will work with the existing implementation (i.e. without the __)?
Yes, it should.
@0xC0000054 xamarin/xamarin-macios#19064 (comment)
as suggested, the .dylib will not be supported in Appstore.
The other option is to use .framework but that requires all dllImport changes. Is it possible to add a check something like iOS ? __Internal : libheif
and enforce th built lib to be .a for iOS. to get .a from .framework is not an issue.
Is it possible to add a check something like iOS ? __Internal : libheifand enforce th built lib to be .a for iOS.
I do not think so, the DllImport
library name is a compile-time constant.
I am not sure what the best way to handle this is.
Looking through the .NET runtime repo issues related to __Internal
, it appears that you may be able to use NativeLibrary.SetDllImportResolver in your application to redirect DllImport
requests for libheif
to the appropriate native module. See dotnet/runtime#7267 (comment)
Here is a test build with the above mentioned DllImportResolver change: LibHeifSharp-iOS-test.zip
This version is built against .NET 7.0, in theory it should work on iOS.