Mobile devices have become a huge part of our lives, every day we’re using them to access a lot of information, from the regular and old emails to the overused social media apps, we’re all day long handling them.
As an app developer the challenge is bigger now, there are a lot of different platforms we need to provide content for, and almost every time the idea remains the same: we want to reach all users regardless of the platform they use, and to achieve this we must develop our apps for multiple different platforms which increases the time and money we spend on creating new content.
For example, to make a new app accessible for Android and iOS devices we must create it using two completely different programming languages (Swift or Objective-C for iOS and Java or Kotlin for Android) which requires you to understand the specifics of each platform and to write the app twice in this case. Also in the case of any update or change in your app, you must foresee that this must be done using the mentioned platforms… and what if you later want to make your app also available for Windows users?
To avoid the need for writing multiple times the same application we can use a framework, using the “write once deploy everywhere” approach. We can find out there a huge variety of frameworks using different languages and offering native, web or hybrid results. Xamarin is one of those frameworks… let’s see what makes it so special.
What is Xamarin?
Xamarin is a technology for creating 100% native mobile applications for a variety of platforms, among which we have Android and iOS mobile.
Let’s break this down, imagine we are intending to create a new app for challenging friends to answer some general knowledge questions, so most of our friends have Android-based mobile phones and because of this we decide to create the app using this platform (using Java or Kotlin).
But hey, John is one of our dearest friends and he uses an iOS-based phone, so he feels kind of isolated from the group. So we decided to go ahead and create now the version for iOS using the Xcode platform (using Objective-c or Swift). Now that we have versions for these two platforms everyone is happy in my group of friends, but now they’re asking me to add some more features to the app. Keeping both applications synchronized in their features is a hard job…
Xamarin helps you with that, by allowing you to write a shared code (using C#), that will be converted later to native code for each platform
Among the features Xamarin provides we have:
- Mobile cross-platform development
- Objective-C, Java, C, and C++ Interop
- C# based development
- Access to the .NET BCL (Base Class Library)
- Xamarin.Essentials (A cross-platform library for accessing native features)
When developing a mobile application using Xamarin we can create a common logic among the different platforms, but an important part of this development relies on the user interface (UI). Each platform has its own and very particular way to display and deal with interfaces, thus it is our job is to create applications that not only behave natively but also look native.
Xamarin.Forms provide an abstraction for creating UI elements across platforms
The main goal of Xamarin.Forms is to allow us to share UI layout and design across platforms. These common interfaces can be written in XAML (eXtensible Application Markup Language) with code-behind in C#, and are rendered as performant native controls on each platform.
To write apps in Xamarin and Xamarin.Forms we can make use of the Visual Studio for PC or Mac, in both the code will run exactly the same. To install them you can find a step-by-step guide here for pc, or here for Mac.
Let’s go further and create our first application using Xamarin