What is Xamarin? How does it help in cross-platform mobile app development?

With the recent technological advancements in the Mobile sphere these days, we can use a phone to do almost anything. The major mobile market share is held with Google’s Android. Followed by Apple’s iOS and then Microsoft’s Windows. If you are a budding mobile developer, at a point you may face this most crucial situation. Where you would want to run your app on a platform different from which it was designed for.

But learning a new language, the APIs, and other stuff may seem a tedious task and it can make you stick to your platform. But something called Xamarin can help you build cross-platform mobile applications that can perform almost similar to the platform native applications.

What is Xamarin

Xamarin

Xamarin is a software company founded back in 2011. And it was recently in 2016 that it was acquired by Microsoft. Xamarin provides a developer with tools that can help them in building cross-platform mobile applications. The applications can have all the native features and also share the common codebase at the same time. As per Xamarin stats, more than 15000 companies rely on their tools and the list includes many big names out there.

Xamarin tools are available to download with Visual Studio and you can directly create Android, iOS and Windows apps from Visual Studio itself. Most of the common code is written in C#. So you don’t need to learn Java, Objective-C or Swift to build apps if you already know C#. If you are a beginner, then taking the Xamarin path instead of the conventional learning process can actually teach you app development for more than one platforms. But will you miss out on real native functionality?

The answer to that question is mostly No. The great set of features provided by the entire toolset makes sure you don’t miss out on any functionality. But at some point, where you might want to dig a lot deeper. Xamarin lets you call existing code written in other platform-specific languages such as Java in Android. But that is only when you are building something very specific which cannot be implemented on different platforms.

Xamarin supports wearable devices as well. You can build native applications for Android Wear and Apple Watch as well. The Xamarin component store lets you add more functionality to your apps by downloading simple plugins. You can easily integrate your application with most of the popular backends like Microsoft Azure, Parse and etc. You can add popular authentication methods as well. And also, plugins to add billing support and other features are available as well. Most of the popular plugins are cross-platform but platform specific plugins are available as well, for example, the Google Play billing support plugin.

How does Xamarin work

This is the most asked and peculiar question about this platform. So, what does basically Xamarin does that you can write a common code for different platforms? At the very root level, Xamarin has converted the entire existing Android and iOS SDK to C# so that you can code in a more familiar language. And as you can use C# to code for both the platforms, you need to remember less of syntax. You can access almost any iOS or Android API in C# with the Xamarin tools.

Now coming to its UI, the UI remains pretty much the same. You need to build the UI separately for different platforms and then bind the UI with the common codebase. Here is a picture from Xamarin website that I would like to share so that you can understand better what is happening under the hood.

So, you can build actual native application UI. Such UIs not only provide the user with required feel but also the apps behave as if they were normal native apps. Below the platform specific UI code, is the shared C# code that calls the common codebase.

There are actually two different ways to build the UI. You can use the original native methods to build the UI or you can use Xamarin.Forms. Forms let you build UI for different platforms all at once. There is almost 100% code sharing if you decide to choose Forms over Native UI Technology.

After doing the UI comes the most difficult part in which you need to connect the UI to the codebase. And that again can be done by two different code sharing strategies called ‘Shared Project’ or ‘Portable Class Libraries’.

Resource

Add a Comment

Your email address will not be published. Required fields are marked *