I have need to create C# bindings for Swift and Android libs. I am looking for a tutorial on doing same.
For Android
Binding Java libraries: https://learn.microsoft.com/en-us/xamarin/android/platform/binding-java-library/.
Binding Kotlin libraries: https://learn.microsoft.com/en-us/xamarin/android/platform/binding-kotlin-library/
For iOS
Binding Objective-C libraries : https://learn.microsoft.com/en-us/xamarin/ios/platform/binding-objective-c/
Binding Swift libraries : https://learn.microsoft.com/en-us/xamarin/ios/platform/binding-swift/
Related
I've started a new Xamarin project using MvvmCross 6.2.1 which requires netstandard 2.0 or better. However attempting to refernce my PCL project from my iOS project I get an error message claiming that the PCL project has an Incompatible target framework: .NETCoreApp, version=v2.1. How do I solve this problem?
I'd like to build a PCL library, starting from an existing C++ code. This code has some dependencies (SDL, which is available as a NuGet package) and I'd like to know if it's feasible to integrate it in a Xamarin solution (which targets Xamarin.iOS, Xamarin.Android and Xamarin.Mac).
More precisely, the code is hosted here : https://github.com/chunying/gaminganywhere/tree/master/ga/client
If so, do I need to use C++/CX language ?
Hey I'm a Xamarin beginner who is a bit confused on how to structure my app to ensure cross-platform functionality while writing the smallest amount of code necessary. I have a library written in C and when using this library previously I would go the NDK route(for android), I now have to use the library for my Xamarin.Android and Xamarin.ios app. I want to know what the best way of achieving this goal is. Do I create a shared library or a PCL? Do I find a way to compile the library into a dll and just include in the Xamarin project?
Linking to C "native" libraries does not really change because you are using Xamarin, you still need to build all the various ARCH types, create universal/fat libs, etc...
On iOS you would be linking to a static lib or loading a .dylib:
iOS Linking/Interop Native Libraries
On Android you would be using your .so just like NDK (Xamarin.Android produces an NDK-based app):
Using Native Libraries on Android
*Note: If you are using Visual Studio, you also can debug your 'native' C/C++ along side your Xamarin.Android C# project.
In your C# code, in order to access methods defined in either one of those, you use Mono's P/Invoke functionality which is the same technology that you would use in .NET to access functions in C-based libraries.
Accessing C Methods from C#
When creating a binding project for a java library that requires the Android Support Library, how should the reference be added? Should the Xamarin Support Libraries be used or should the suport lib jar file be included in the project with a ReferenceJar build type?
I've done it by including the appropriate Xamarin Support Library via Nuget. (You might be able to do it by including the reference jar but I'm not sure)
I would like to use tesseract ocr for Xamarin.Android and Xamarin.iOS applications.
I found the binding for iOS (https://github.com/jherby2k/Xamarin-Tesseract-OCR-iOS-Unified).
Is there an equivalent for Android ?
Yes, there is Tesseract for Android implementation. You can find it here. But you'll have to build it and create android bindings by yourself.
EDIT
I created Xamarin Android binding based on this project. You can find it here. There is a test project, just don't forget that you will need Tesseract testdata to be copied on the device.