Xamarin Architect Feature

Using Xamarin.Forms, .NET developers can create mobile apps user interfaces faster. This is done by extending the Xamarin framework with a shared abstraction of the common UI objects of each platform. In this article, I will share more about how Xamarin.Forms work and whether or not this can benefit you with your cross-platform efforts.

What is Xamarin.Forms?

Reports show that mobile apps are projected to hit $581.9 billion in revenue in 2020. (Statista) and this number is still growing. This shows the importance of mobile applications, especially to a business with an online presence. Having a mobile application is a necessity.

Business owners who do not have a mobile app yet may choose to develop mobile-friendly websites. You can include design features that are readable on a mobile device. You can achieve this by building a website that is responsive using Hypertext Markup Language (HTML), Cascading Stylesheet (CSS), and JavaScript. This may be a very valid approach for your particular needs, but you are limited on what native mobile device features can offer. Depending on your needs for access to device-specific features, you could develop applications in the software development environments provided by each platform provider, Objective-C or Swift for iOS development, and Java or Kotlin for Android.

If you know web development, you may consider going hybrid and develop just a single code that allows you to run on multiple platforms. You can accomplish this by having the native web view component on each platform with open-source SDK such as Ionic. Ionic is built as a set of Web Components, allowing the user to choose any user interface framework, such as Angular, React or Vue.js. The only drawback is — as an interpreted language, JavaScript has some performance bottlenecks so not really ideal for the hybrid approach.

If you have skills with C# or F#, Xamarin will work best for you. Xamarin allows you to create an abstraction layer using the native platform and helps you develop the app in a more common language. While not as robust, it isn’t that bad as you are able to develop a common language. So where does Xamarin.Forms come in?

Defining Xamarin

Using the .NET framework, you can create applications across several platforms with Xamarin. You can do the development using Windows or Apple (iOS) operating systems. Everything is accomplished through the Mono framework and allows you to share a common library.

When developing the Xamarin project using the iOS platform, you will first need to create a Visual Studio project. With iOS, you start with an application logic within the project, creating interaction and using the MVC design pattern. All this using the .NET Framework. You can also take this one step further through a shared library project. Using the Windows operating system, you will be creating a .NET project by selecting the Xamarin platform.

What is Xamarin.Forms?

With each project, Xamarin.Forms create an abstraction that provides a common API and allows your shared project to reference native UI objects. Because the shared library can interact and create with the presentation layer, you can then move the user interface into the shared library. Application flow and business logic have been moved to the shared library too, which means that communication with the device has been lost as the platform’s application logic no longer drives the application. Communication through a proxy is needed since the shared logic is not able to communicate with the device features. The image below shows how the library is being shared by both Android and iOS.

Xamarin Architecture, Shared Components

Xamarin.Essentials — a library, works well with Xamarin.Forms. It’s a NuGet package that also creates abstraction and allows you to communicate features with the common API. This is a good picture – however, you may need platform-specific logic developed still. Don’t worry though as Xamarin is extremely flexible. A Xamarin.Forms application declares the user interface in one or more XAML files. Here we see a very basic XAML file. Xamarin.Forms can be built up and referenced programmatically, but for now, let’s focus on the XAML declarations.

Summary

Although Xamarin.Forms and Xamarin.Essentials can be used independently, they also work well together. With Xamarin.Forms, you can get started with developing your own mobile applications. With Xamarin.Forms, you can jump right into the development of your application. If you are interested in a deeper dive into the full Xamarin ecosystem, please contact our team at Agile Tech. We have done many Xamarin applications for our clients. Below are a couple of sample screenshots of our work.

Android app for Zebra
Android and iOS mobile apps