April 8, 2015

Understanding the Xamarin Framework

What is Xamarin?

Xamarin is a framework to develop a cross platform mobile application using C#.

There are a number of frameworks that offer cross platform app development. They typically use HTML and JavaScript. Using these frameworks, apps are developed like a website for a mobile app using JS libraries, then the website is packed in a container which gives the feel of a native app. There are some disadvantages of this framework: first, you will not be able to access native UI elements. Second, the app runs slowly and does not give the feel of a native app.

Xamarin is different because it offers a single language C# and runtime that works on three mobile platforms (Android, iOS and Windows). From Xamarin we get a mobile app which looks and feels completely native. Here we write one C# code base which will have access to all features which are available for native SDK.

Why use Xamarin?

Xamarin combines all of the power of the native platforms and includes many features of its own.

  1. Xamarin applications are developed using C# which is a modern language and has many improvements over Objective-C and Java
  2. Xamarin provides the facility to directly include Objective-C, Java and C++ libraries. This will give you the ability to reuse many 3rd party code bases which are in Java, Objective-C or C++
  3. Xamarin offers cross-platform support for three major mobile platforms (Android, iOS and Windows). Application can share up to 90% of their code base
  4. Xamarin reduces the time and cost of mobile app development
  5. Xamarin provides a massive collection of class libraries
  6. Xamarin provide robust compile time checking. This will lead to fewer run time errors and high quality applications.

How Does Xamarin Work?

Xamarin gives the flexibility to write core logic using C# and gives the flexibility to design native user interface specifically for each platform. The amount of code re-use will depend on how much code is kept in core and how much moves into user-interface.


C# source compiled into a native app in very different for each platform

  • iOS - C# source code is compiled using Xamarin.iOS. It uses a special subset of the mono framework. This subset version of the mono framework has additional libraries. The framework itself allows access to iOS platform specific features. The Xamarin.iOS compiler compiles source code into an intermediate language that is known as ECMA CIL (common intermediate language). After compilation of Xamarin.iOS application code into CIL there is needs to compile it again into native machine code that can run on an iOS device. The process of converting CIL into native code is carried out by the SDK tool “Mtouch.” “Mtouch” returns an application bundle that can be deployed to either the iOS simulator or an actual iOS device, such as an iPhone or iPad. The iOS kernel will not allow programs to generate code at runtime. This restriction is placed by Apple iOS kernel. This restriction has great implications for software systems that run inside a virtual machine using just-in-time compilation. This type of compilation coverts code into intermediate language and at runtime this is converted into machine code. The converted machine code becomes compatible with devices on which it is running. To work around this restriction the “Mtouch” tool compiles the CIL ahead of time.
  • Android - Code of C# is compiled to intermediate language with a package of MonoVM + JIT. If there are any unused classes of framework then in linking it is stripped out. The application runs interact with the java native types through JNI (Java Native Invoke)
  • Windows - Code of C# is compiled to intermediate language which will be executed by the built in runtime. This compiled code does not require Xamarin tools.

How to setup Xamarin?

Four steps to setup the Xamarin

  • Download the Xamarin installer
  • Run the installer
  • Configuration
  • Activation
  1. Download the Xamarin installer

First, download Xamarin from here.

Xamarin 2

Fill the required information to download the Xamarin installer.


After download the Xamarin installer, run the installer.

2. Run the installer

Steps to run Xamarin installer









After installing Xamarin, we need to configure the Xamarin to tell them (Xamarin and VS IDE) the location of Java and Android SDK.

When we install the installer places the installed component in their default location and configure the development environment with these default path. But if we already have these components in our system, then we need to change the path.

To configure SDK locations in Xamarin, go to Xamarin studio, select tool->options-> SDK location


Configure Visual Studio

To configure the Visual Studio, go to Visual Studio.

Path is tool->options->Xamarin

4. Activation

It’s time to activate your account, go to Xamarin studio, click on login and create your free trail account, now you can login your account.







Xamarin Test Cloud

Nowadays internet usages are increasing. Internet usages from mobile devices are increasing very rapidly. This tremendous growth gives the challenge of staying competitive and offering superior user experience on various devices.

Xamarin Test Cloud is used to test a mobile application on diverse devices. Xamarin Test Cloud is used for automated testing on many real devices simultaneously. It is an integrated testing framework.


  • 4x faster to get to test results Vs. Manual testing
  • Reduce overhead and expenses.
  • Test over a thousand real devices.
  • Script and automate your app with C# or Ruby
  • Analyze your app performance
  • Test continuously