Please help with Native Library #6872
Replies: 7 comments 3 replies
-
I separate .dll and .so to different library, see https://github.com/xtuzy/ApplePDF/tree/ApplePDF, if use single project manage they, maybe need use |
Beta Was this translation helpful? Give feedback.
-
Thanks xtuzy, I tried couple approaches based on your example, but with no success
I received next build errors
Could you please suggest what am I doing wrong ? Also, attaching libtest_lib.dylib in case you would have time to please take a look and suggest if anything is wrong with the library Thanks |
Beta Was this translation helpful? Give feedback.
-
you are using a dynamic library , apple store not accept it , if you have a static library, you can see a best example at https://docs.microsoft.com/en-us/xamarin/cross-platform/cpp/ |
Beta Was this translation helpful? Give feedback.
-
Thanks xtuzy for the suggestion, I saw this great tutorial. The only difference : he creates iOS binding project and packs to Nuget package and later reference the Nuget package. What I am trying to do is to create iOS binding project and conditionally reference to the MAUI application and receive the errors I indicated above
This is where I need help - the issue is very simple to reproduce
Any suggestions please ? |
Beta Was this translation helpful? Give feedback.
-
Thanks xtuzy, I am following the steps from your project, however still not able to make it working on the iOS. Attaching simple solution which has Shared project (NativeLib.Shared), projects per Platform, combined (NativeLib) and consumer (NativeLib.Maui) where I call NativeLib inside MainPage.xaml.cs. Could you please take a look. Your help is much appreciated, thanks ! |
Beta Was this translation helpful? Give feedback.
-
As always, thanks a lot xtuzy! Unfortunately, it still not working for my iPad. I keep looking for the solution, thanks anyway |
Beta Was this translation helpful? Give feedback.
-
Is there any solution? I hope to find a example and a guide. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I am using MAUI to build the cross-platform application and want to use existing c++ native library already built per platform
So, here is the setup I have (attaching the Visual Studio test solution)
Pre-built NativeLib
i. NativeLib.Windows.x64.dll
ii. NativeLib.Android.arm64.so
iii. NativeLib.iOS.arm64.dylib
NativeLibTest.Import - .NET library to
i. Reference NativeLib(s) above
ii. Define the DllImport(s)
iii. Wrap DllImport(s) into .NET style API
NativeLibTest.MAUI - sample MAUI application which uses NativeLibTest.Import
Now, here are a few questions I need help please :
I am adding NativeLib.Windows.x64.dll to the NativeLibTest.Import.csproj and it is later properly copied to NativeLibTest.MAUI Windows App during the deployment and everything works fine
However, when I am adding NativeLib.Android.arm64.so in a similar way, it is not copied to NativeLibTest.MAUI Android App during the deployment. Another option is to add by using , but this doesn't seem to work in .NET library project
So, for Android I have to add NativeLib.Android.arm64.so to the NativeLibTest.MAUI.csproj and in such case NativeLib.Android.arm64.so properly copied during the deployment and works. But, this is very inconvenient as I want to have NativeLib.Android.arm64.so on the NativeLibTest.Import library level and not on the application level
For iOS, I am trying approach similar to Windows, but it doesn’t work. I am also trying to add NativeLib.iOS.arm64.dylib by in the NativeLibTest.Import.csproj and NativeLibTest.MAUI.csproj, but doesn’t work
The suggested topic https://docs.microsoft.com/en-us/xamarin/ios/platform/native-interop says to use MonoTouch.ObjCRuntime.Dlfcn.dlopen ("/full/path/to/Animal.dylib", 0); but I am not exactly sure how to use this in the NativeLibTest.Import library project
Adding Visual Studio test solution :
NativeLibTest.zip
Please help
Thanks
Beta Was this translation helpful? Give feedback.
All reactions