We live in a world where more than 80% of connected devices sold are smartphones and tablets.Unfortunately the market is heavily fragmented with 3 major Platform providers, namely iOS, Android and Windows. This poses a huge challenge for Companies as they may have to build mobile applications for each of the  platforms and is often an impediment to a successful mobile strategy.

This is where our Mobile COE has been helping customers with coming up with an ideal mobile strategy for the last few years. Our team, over the years have done extensive research and various experiments with a variety of cross-platform tools and technologies using which one can develop mobile applications that can run on multiple platforms. Titanium, Sencha, Apache Cordova, IBM Worklight, Oracle MAF and Xamarin are few of them. Depending on the nature of the App, Business, Geography, Users etc. we have recommended the right cross-platform tool to build mobile applications. Xamarin is a new entrant to this race and we at the Mobile COE are in awe of this framework. What makes Xamarin special is the fact that it gives cross platform support and native performance at the same time.

Unlike the other frameworks, what makes Xamarin special is its run time performance. The framework allows the developers to write code in C# language and then compile the code into a native mobile or tablet application and deploy it. They can focus on the functional solution and  leave the nuances and complexities of the underlying platform to the framework. The framework treats each underlying platform separately. In the case of Android, once an application is written using this framework, the application gets compiled into a Common intermediate Language and a Mono run time gets bundled along with it into the application. The mono run time does a just in time compilation and also takes care of memory management, reflection etc. The framework works a little different in the case of IOS as IOS kernel does not allow programs to generate code at run time . Here the compilation is a 2 step process. First, the common c# code gets compiled into the Common Intermediate Language and second, since IOS does not support “Just In Time” compilation, another compiler called mtouch would do an AOT or “Ahead Of Time” compilation and converts to machine code. In both cases we get compiled code that is either AOT compiled or JIT compiled and brings with it native app performance. In some scenarios the Android apps that are built using Xamarin are faster than apps build using the native android SDK.

Broadly there are two different approaches to building cross platform apps using Xamarin

1. Native UI
2. Xamarin Forms

Native UI
Xamarin allows developers to create UI the way they used to create UI with XCode or Android Studio. The UI will be platform specific and cannot be reused. The reusable code would be the business logic which can either be put in a Portable Class Library or under a Shared project. In case of iOS the UI can be created in 3 ways

a. Xamarin iOS Designer
b. Xcode Interface Builder
c. Using UI APIs

And in case of Android the UI is created using Xamarin Android Designer.

Xamarin.Forms
Forms provide a UI tool kit abstraction that allows developers to create User Interfaces that can be shared across Android, IOS and Windows. The user interfaces are rendered using the native controls of the target platform, allowing Xamarin.Forms applications to retain the appropriate look and feel for each platform. Applications written using Xamarin.Forms are able to utilize any of the APIs or features of the underlying platform, such as (but not limited to) CoreMotion, PassKit, and StoreKit on iOS; NFC and Google Play Services on Android; and Tiles on Windows Phone. This also means it is possible to create applications that will have parts of their user interface created with Xamarin.Forms while other parts are created using the native UI toolkit. There are two techniques to create user interfaces in Xamarin.Forms. The first one is to create UI views entirely with source code using the rich API provided by Xamarin.Forms. The other option available is to use Extensible Application Markup Language (XAML), a declarative markup language from Microsoft that is used to describe user interfaces. The user interface itself is defined in an XML file using the XAML syntax, while run time behaviour is defined in a separate code-behind file.