What is Xamarin?
Xamarin is a platform for developing fully native applications for iOS, Android and Windows, with a shared code base. Xamarin apps are written in C# and can make use of most .NET libraries.
- Xamarin apps are native so the performance is great.
- Everything that can be done with native app development can be done with Xamarin. All native Android, iOS and Windows API’s are available.
- The UI is native. Xamarin Android apps use the same design guide lines as other Android apps. This is important because the user will have a similar user experience with your app as with other apps. Same goes for iOS and Windows apps.
- You only need to know or learn one language to develop for all three platforms.
Some background information
Some of you might be confused now because .NET only runs on Windows right? No that’s not completely true so I want to start with some background information about CLI and Mono.
In 2000 Microsoft released the Common Language Infrastructure (CLI). This is an open specification and is standardized by ISO and ECMA. The CLI describes how high-level language applications can run on different platforms without changing the code. There are a few implementations of the CLI like .NET Framework, .NET Core, Mono and more. The .NET Framework is the most used and most well-known implementation which only runs on Windows.
Mono is a CLI implementation that runs on Windows, Linux, Mac and even Embedded systems. Mono makes it possible to write applications with WinForms, WCF, ADO.NET, Entity Framework and more in languages like C#, F#, VB.NET, Python and more. Mono is also available for iOS as Xamarin.iOS, previously named MonoTouch and Xamarin Android, previously named Mono for Android and MonoDroid.
How does Xamarin work?
When you scaffold a Xamarin app you get multiple projects. The number of projects you get depends on which platforms you want to support. The first project is a class library which contains all the code shared between all the supported platforms. You also have one project for each platform you want to support. Those projects contain all of the platform specific code.
Xamarin contains binding for the iOS and Android SDKs. So Xamarin code looks pretty much like the code you would write when developing a native app. I’ve written a very simple Android example to show you what it looks like. It’s an app which fetches some information about countries from a webservice and show them in a list. It also has a switch. If the switch is turned on it shows the country codes and when turned off the app won’t show the country codes. The code should look very familiar to Android developers.