Using native iOS SDK and Android SDKs in Xamarin apps.

I've been doing iOS development for a few years now and I know Android dev probably enough to build a "Hello World"x4 app but I'm completely new to Xamarin. My company has built some app in native code and some in Xamarin, my team has been assigned the task to figure out how to create portable component that can be used across native and Xamarin apps. Based on some initial reading I think the below is possible but asking here for some validation and also asking for pointer to any official documentation (and hopefully code samples) on how this should be architected in the Xamarin side. So this is what we have on mind:

Assume these are our requirements.

Create a component that is sharable across native and Xamarin apps that makes an REST API call. The API returns a "Hello World" string, the string needs to be displayed in the middle of the UI and a text field should be also added along with a Send button. When the Send button is pressed the content of the text field is sent to the backend. And there is an API to change the background color of the component. This is just to excerscise some basic communication between the component and the host app (native or Xamarin).

This is what we are thinking:
1. Create an iOS SDK that encapsulated the view component and the logic to call the backend. It also exposes the view APIs to read the text from the text field and change the background color.
2. Build #1 for Android.
3. Create a binding library for iOS in Xamarin and use the iOS SDK from #1
4. Create a binding library for Android in Xamarin and use the Android SDK from #2
5. Use these binding libraries in a Xamarin app
6. Use the original native SDKs in the respective native apps.

So #3, #4 and #5 are the places where I feel we need a huge knowledge gap on How To and if that is the correct approach. Also in #5, it sound that we end up with two different bindings one for iOS and one for Android, I read something about NuGet packages. Would that wrap both into a unified Xamarin package that is used in the Xamarin app?

Any pointers to documentation, code samples, case studies would be great. I'm really looking forward to learning Xamarin!



  • MaxenceMaxMaxenceMax Member ✭✭

    I agree from A to Z with you.

    If Xamarin brings an easy way to integrate native framework / library, it will be one of the best approaches to mobile development.

  • lahellerlaheller USMember ✭✭
    edited January 14

    For Android only:

    Binding a JAR/AAR library can be quite easy. You have to create a binding project in Visual Studio, add the JAR/AAR library and just build it. The result DLL library you can use in another project.

    Native Android library (.so files) binding is much harder. For this you need to know at least the headers of original (C++) library functions, their parameter types, return values, etc and create a C# wrapper library for them.
    This is really an advenced topic, you can read about theory here.

Sign In or Register to comment.