Mobile development has many technologies divided by platforms, development environments and programming languages that involve a learning effort and continuous work for developers.
However, in recent years, technological alternatives have emerged that allow cross-platform applications sharing a single code , or a good part of it, but whose result is similar to a native compilation.
This leads to more fluid and energy-efficient applications compared to hybrids. Among these alternatives today in this article we are going to focus on what exactly Xamarin is.
What is Xamarin?
Xamarin is an app development environment that, using C # code for the logic and XAML for the views, compiles natively for multiple platforms (iOS, Android, WP8, UWP, Mac…).
Xamarin user license is very costly but last year it was acquired by Microsoft and became free. It has a community and superior support compared to other solutions, which makes it an option to consider.
Xamarin for Cross-Platform Application Development
Many people only know that Xamarin offers native applications on Android and iOS, but it does not, in addition to those already mentioned it also allows you to create applications for:
- UWP : It is the universal Windows platform for all your devices, say, PCs, Xbox, mobile devices, IoT, HoloLens, among others.
- Mac : Support for running applications on macOS, the operating system used in Apple computers and laptops.
- GTK # : A set of user interface tools that allows us to bring our applications to the Linux operating system.
- Tizen : To develop applications that run on Samsung devices such as TVs, mobile devices, IoT, among others.
Initially, Xamarin Native is only existed (also called Classic) but in 2014 Xamarin Forms was introduced. Both share the philosophy of minimizing the use of code but differ completely in the way they approach their development as well as the resulting product.
Through native binding, it communicates with the native APIs of the system and the native components such as Activities, ViewControllers, Fragments or Views are implemented through classes and methods.
Creating views is similar to native views using Storyboards and XML. The MVVM pattern is integrated but MvvmCross library is widely used for this.
Something to keep in mind is that you need to create a project for each operating system since the objects, calls and architecture in general are completely different from each other.
That is, it is possible to share code for common functionalities but then the generation of the views and their interaction with the data must be platform specific.
In order to minimize development time, Xamarin Forms maximizes the amount of code shared between platforms. With it, the common code is not only for isolated tasks but it is possible to design all the functionalities and views of the application.
With C # language for logic and XAML for views instead of JS + HTML5 + CSS3 or Lua among others. In this case, the MVVM pattern with two-way data binding is perfectly integrated without the need to use external libraries.
The most important feature is that it automatically generates custom visual components for each platform.
Classes and methods are unified yet are still recognizable to a mobile developer. For example instead of a ViewController or Activity there will be a Page. However, for certain functionalities, it is still necessary to supplement with code in the specific project of each platform.