This article was co-writen with Alejandro Eliseche, Sr Mobile Developer at Making Sense.
First things first: What is Xamarin?
Xamarin is a tool used for cross-platform mobile app development that allows developers to share about 90% of the code across main platforms.
It is a fairly new technology that already has a large community of developers. Xamarin was created by the developers behind the Mono project, and then acquired by Microsoft in 2016.
Here’s why the developer community has flocked to Xamarin:
- It’s open-source (based on Microsoft technology).
- It uses C# as a programming language*.
- It’s fully integrated with the Visual Studio IDE.
*Developers love C# because it encompasses several functions that they find to be very useful (LINQ and asynchronous programming (Async), for example).
These important features mean there’s no need to use Java for Android or Objective-C / Swift for iOS applications. The real beauty of this is that, unlike other cross-platform solutions, Xamarin is compiled natively. This is key when it comes to creating applications that deliver excellent results in performance and user experience.
And, since business logic, database access and network communication can be shared, Xamarin allows for the creation of a platform-specific UI code layer. That means we can generate apps that look 100% native on any device. This also provides a better User Experience compared to hybrid applications.
The Advantages of Xamarin
- SHARED CODE:
Xamarin uses C# complemented with .NET Framework to create applications for mobile platforms (iOS, Windows Phone and Android), sharing up to 90% of the code. This implies considerable savings in time and resources.
Another important consideration is the use of .Net Standard, whose multi-platform, open-source design translates into even more benefits for the developer. It is modular and is downloaded via Nuget, focusing its characteristics on separate packages, making it more scalable and using what is necessary for development.
- MOBILE APPLICATION TESTING:
Xamarin provides us with a framework (Xamarin Test Cloud) that can automate and test any iOS or Android application on thousands of mobile devices. It provides both the automation framework and the device cloud, so you can offer integration testing as well as continuous improvements.
- NATIVE EXPERIENCES WITH EXCELLENT PERFORMANCE:
Xamarin provides a native user interface, giving access to all mobile hardware. Using Xamarin, we obtain 100% native applications, as if they had been coded in Objective-C, Swift or Java. This also ensures an excellent user experience, something of utmost importance in any application.
Xamarin offers developers a choice in how they want to create applications. One way is to use Xamarin.iOS and Xamarin.Android. A second option is through the use of Xamarin.Forms. This second option allows us to quickly generate prototypes or applications with fewer platform-specific functionalities.
Xamarin.Forms is the best option when sharing code within the app is more important than the user interface for each platform. The key is that it enables the creation of a single user interface to share between platforms. We can also create applications where some parts of the interfaces are made with Xamarin.Forms and the rest are designed using the native UI toolkit.
- PROVIDES TOTAL ACCESS TO THE API OF EACH PLATFORM:
Xamarin eliminates certain limitations posed by other methods, especially in terms of operating system updates. We get the functionality of a native application by using add-ons and specific APIs. These allow us to work with the common functionality of devices on all platforms. Along with allowing access to platform-specific APIs, Xamarin allows native libraries to be linked. This paves the way for greater customization and native functionality without very much extra effort at all.
- MAXIMUM PROFITABILITY:
Reusing code translates into greater profitability since there’s no need to retain different teams of developers for each platform. A single team can develop the application for all platforms with a native result and an excellent user experience.
- ADVANTAGES OF C #:
The main advantages of using C# are that 1) it is the most powerful programming language for the .NET Framework and 2) it possesses great flexibility. It supports most paradigms, highlighting the functional paradigm that combined with the object-oriented paradigm, makes this language one of the most powerful.
The Cons of Xamarin
- DELAYS IN PLATFORM UPDATES:
When the Xamarin development team issues an update, Microsoft is good about providing support for the update on the day of its release. The problem is, however, there’s often some sort of delay. This isn’t usually a significant problem, however, unless the delay is extremely drawn out.
- A BASIC KNOWLEDGE OF NATIVE LANGUAGES IS REQUIRED:
In order to develop applications using Xamarin.iOS and Xamarin.Android with a truly native feel, you need to write a specific code layer for each platform. This implies having a basic knowledge of native languages (Java / Kotlin for Android and Objective- C / Swift for iOS) as well as the SDK. This does not apply to the use of Xamarin.Forms.
- LARGER SIZE OF APPLICATION:
Applications developed using Xamarin are usually larger than those developed natively. Much of this is due to the size of the associated libraries, content, Mono runtime, and Base Class Library (BCL) assemblies. Therefore, Xamarin applications generally need additional optimization if the file size of the application is to remain reasonably small.
- COMPATIBILITY PROBLEMS WITH THIRD-PARTY LIBRARIES AND TOOLS:
When using Xamarin, you may run into issues when you try to integrate third-party resources into your application. Xamarin has its own component store but it doesn’t cover everything. Developers should always be aware of the likelihood that they’ll need to integrate something specific which was not provided in the store.
What Developers are Talking About: Xamarin Vs. React Native
Both React Native (Facebook) and Xamarin are excellent options for reducing development time and costs without sacrificing quality, performance and user experience.
This is a summary of the key aspects to consider:
- Cost. Costs are likely to be similar for Xamarin and RN, but Xamarin’s licensing conditions are more straightforward and less restrictive.
- Flexibility. React Native offers much more flexibility than Xamarin in the choice of an IDE.
- Language. Both frameworks use popular coding languages so your company’s language preference will play an important role in selecting whether to use React Native or Xamarin.
- OS. React native only supports Android and iOS, whereas Xamarin supports them as well as Windows Mobile, Android Wear, iOS Watch, Android TV, Mac and Windows Universal App.
Xamarin is an excellent alternative for the multiplatform development of mobile applications. By using an appropriate architecture such as MVVM, we can reuse 90% of the code. This generates a significant savings in development time, maintenance of the application, and client costs. Beyond these benefits, Xamarin-developed apps deliver results on par with apps that were developed natively in terms of performance and user experience.
And if all this doesn’t satisfy your needs and you’re still looking for a more agile solution, there’s always Xamarin.Forms. Like Xamarin, this tool helps you create apps that will continue delivering excellent results and top quality well into the future of your product.