5 Reasons to Choose Xamarin for Cross-platform Development

Xamarin is one of the most popular cross-platform app development tools for iOS, Android, tvOS, watchOS, macOS, and Microsoft (UWP apps) using C # and .NET. In 2019–2020, it was ranked among the five most popular cross-platform mobile frameworks used by software developers worldwide. Such well-known companies as Bosch, Siemens, Slack, Pinterest, UPS, Outback Steakhouse, Aggreko, and others relied on it in their app development projects. In this article, we will share Auriga’s experience in developing an application using Xamarin, discuss why it is worth using, and explain how it was beneficial in our particular case.

cross-platform-mobile-frameworks

Fig. 1 Cross-platform mobile frameworks used by software developers worldwide in 2019 and 2020 (Source: Statista)

Case Study: An Old Application on a New Platform

We have already discussed the migration of outdated applications several times in our blog (for example, here and here). If updating an application or introducing new features to it would require too much money and effort, or if there is no documentation or experts knowing the codebase to support the abovementioned activities, the right solution would be to migrate the outdated application to the new technology stack. Basically, it means writing an application from scratch using the logic and UI of an existing application.

In our case, the Customer’s application was developed in LabView. By the time the project was launched, it had existed for over 10 years. During this time, the project documentation became obsolete. There were no support specialists left, and most importantly, porting the application to a new operating system (OS) was deemed too costly and resource consuming.

The main requirements for new app development were as follows:

  • iOS and Windows support with full reproduction of the old application UI/UX
  • app development within tight deadlines
  • ease of support and scalability for future improvements

Xamarin was an optimal solution given the required tasks, and here is why.

Reason 1: Native Multiplatform Support

Xamarin provides full access to native APIs and tools used across Android, iOS, and Windows platforms. Hence, it can provide nearly native design and performance for every application. This is a good reason to prefer Xamarin-based solutions to its hybrid competitors.

Reason 2. Tight Development Deadlines

App migration always goes hand in hand with a tight deadline, and Xamarin meets this requirement completely. Among its benefits, we can mention:

  • Re-use of one codebase for both iOS and Windows cuts down the development time
  • Ability to use popular and easy-to-learn C # and .NET speeds up the development
  • Installation of Visual Studio is enough to get started

Surveys show that a quarter of developers use this IDE for debugging and working with code.

Xamarin is a powerful and convenient development tool. It allows you to create an app prototype in literally one day and test it without real devices in Visual Studio using simulation models, saving tons of time.

Reason 3. Easy Maintenance and Quick Training

There are several Xamarin tutorials and guidelines. They provide best practices that new engineers can learn to adapt to a project faster. There is also Xamarin University, an online educational portal for those who have just started to explore the package. It is created for engineers with C# knowledge as well as anyone with little programming experience. The resource provides all the necessary information for engineers using Xamarin-based products.

In addition, Xamarin makes it easier to maintain apps. You just make changes or updates to the source file, and they are automatically applied to iOS, Android, and Windows apps. However, keep in mind that it only works for applications using Xamarin.Forms.

Reason 4. Choice of Priorities

There are two approaches to app development in Xamarin – Forms and Native.

xamarin-graph

Fig. 2 Pros and cons of Xamarin development approaches

Figure 2 shows important criteria for choosing between these approaches to app development.

Performance was not that important for our application, and we chose the Xamarin.Forms approach based on the other criteria.

Thus, choose Xamarin.Forms to develop:

  • MVP (Minimum Viable Product) applications
  • Simple applications with limited functionality

Choose Xamarin.Native to develop:

  • High-load systems
  • Applications integrated with other services
  • Applications where the user interface is more important than code reuse
Reason 5. Ease of Cross-platform Implementation

It is easy and convenient to perform cross-platform development using Xamarin. You write general code for iOS, Android, and Windows, and Xamarin figures out how to link your code to the native APIs for each platform. In addition, it is possible to write not only generic but also platform-specific code, and Xamarin understands what to do and where to do it. One of the main mechanisms for achieving cross-platform functionality is the smart services capable of making cross-dependent calls (i.e., addressing one or another implementation of a certain functionality depending on the platform). You can not only write platform-specific code in C# but also add it to xml markup. In our case, the iOS version was limited, and part of the graphical interface had to be hidden. Moreover, the sizes of some elements depended on the platform.

To clarify, here is an example. In our project, we used a customer-provided class library written in C++. Let’s call it MedicalLib. MedicalLib was compiled into two different assemblies depending on the platform (static MedicalLib.a for iOS and dynamic MedicalLib.dll for Windows). In addition, it had various wrapper classes (adapter classes) for invoking unmanaged code. The main project (common code base) contained a description of the MedicalLib API (interface), and platform-specific projects for iOS and Windows contained specific implementations of this interface and references to the MedicalLib.a and MedicalLib.dll assemblies, respectively. From the main code, we called certain abstraction functions without thinking about how they were implemented. The Xamarin.Forms mechanisms understood what platform the application was running on, called the required implementation, and loaded a specific assembly.

This process is shown in Figure 3.

xamarim-forms

Fig. 3 Calling platform-dependent functions in Xamarin.Forms

Xamarin Drawbacks

It is certainly important to briefly mention the disadvantages of Xamarin, which we considered when deciding in favor of this tool.

Firstly, the larger size of the written application affects the download speed and the amount of disk space it takes up on the device. In our project, this was not critical, since the application was made for internal purposes and was not intended for widespread use.

Secondly, there are slight update delays for the latest versions of Android and iOS. Supported versions of OSs were prescribed for our application, while end users could not download and install updates without the permission of the organization’s administrator. It gave us time to check and fix defects in the new version of the OS.

Thirdly, the Xamarin developer community is rather young, and despite the Xamarin University efforts and multiple tutorials, it is still challenging to find a developer with hands-on Xamarin experience.

Finally, because the UI code is platform-specific, it would be impractical to use Xamarin for creating complex animations, developing complex custom UIs, and creating games.

Summing Up

Most decision makers choose Xamarin for cross-platform development because it reduces time to market and development costs by reusing code and using a single technology stack. Our team’s experience shows that Xamarin provides the ability to quickly build MVP with minimal engineering costs and test the application for viability.

For applications with complex user interfaces and high system dependencies, the amount of shared code is drastically reduced. Thus, Xamarin cross-platform development loses its main advantages and costs the same in terms of time and money as native solutions. However, using a powerful IDE still retains a number of considerable advantages.