Is there any way to bind native libraries like in Xamarin? I have tried to do some native implementations in the new .NET Maui and haven't had success on it. I would really appreciate if someone has some information about it.
Asked
Active
Viewed 6,307 times
1 Answers
4
Yes, native library bindings are done the same way as in Xamarin, there are two new project templates "Android Java Library Binding" and "iOS Binding Library" just add them and follow regular Xamarin documentation in order to configure it:
- https://learn.microsoft.com/en-us/xamarin/ios/platform/binding-objective-c/
- https://learn.microsoft.com/en-us/xamarin/android/platform/binding-java-library/
For android you can also check this git repo - https://github.com/Bohdandn/MAUI.WebRTC.Demo, unfortunately iOS doesn't compile there.

Bohdan
- 96
- 3
-
Thanks Bohdan, for this and your Github webrtc repo. I have a XF sln to upgrade. I'm hearing on the grapevine from senior iOS Maui devs, and online (e.g. here https://learn.microsoft.com/en-us/answers/questions/1061273/how-to-create-an-ios-binding-library-for-net-maui) that binding libraries for iOS in particular do not work out of the box for Maui using these Xamarin methods. Can anyone point to Maui specific documentation for binding either iOS or Android? I found this video at least https://learn.microsoft.com/en-us/events/dotnetconf-focus-on-maui/binding-native-libraries-for-dotnet-maui – Adam Diament Jan 16 '23 at 09:37
-
1It seems that they still haven't added MAUI specific docs for native bindings. Regard compilation issues - you can track this issue: https://github.com/xamarin/xamarin-macios/issues/16001, problem is in transferring libraries between windows and mac build host, directly on mac everything works. – Bohdan Jan 17 '23 at 23:22