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 by 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’s native applications.
What is Xamarin
Xamarin is a software company founded back in 2011. And 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 platform. 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 platforms, you need to remember less 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 the 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 the 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’.
Getting started with Xamarin
Now let’s check out how to lay your hands on this amazing thing. To use Xamarin on Windows, you need to install Visual Studio. You can download Visual Studio Community for free or purchase a premium license if you don’t have one already. Head over to xamarin.com to download Visual Studio, already configured with Xamarin tools.
Visual Studio is a great IDE by Microsoft that has been widely used to develop Windows applications. Once you are done with installing and setting up Visual Studio, you can create a new ‘Cross-Platform App’ project and get going. You will be prompted to choose some settings and you are done. Visual Studio may take some time for setting up your project.
To know more, you can read the original documentation here. Also, play around the studio and check out the default files in the project to actually know how everything is working under the hood.
Xamarin University
So, you are pretty interested in this thing and you feel that this is the future of mobile applications. If you are serious about learning Xamarin or mobile development, then I suggest you have a look at Xamarin University. The online university provides live online lectures, 1:1 student interaction, the guidance of Xamarin experts, and a lot more. A lot of things are covered in entire curriculum and you can for sure learn a lot. Visit Microsoft for details.