Javascript required
Skip to content Skip to sidebar Skip to footer

What Is Xamarin and How Does It Work

Everything You Need To Know Before Starting Xamarin Development [2020 Edition]

Shankar Madeshvaran

Are you planning to build a cross-platform Android, iOS or Windows app? Before dive into Xamarin development, it is best to look at the several features that the development framework has to offer.

1) Introduction to Xamarin

Xamarin is one of the oldest cross-platform frameworks available. Founded in 2011, Xamarin community has grown to 1.4M developers across 120 countries. The project was acquired by Microsoft in 2016 and became part of its Visual Studio IDE.

The technology is mainly used in enterprise environments and has gained many positive reviews over the years. Xamarin is used by over 15,000 companies in fields like energy, transport, healthcare and others.

2) What is Xamarin?

Xamarin is an open-source platform for building modern and performant applications for iOS , Android , and Windows with .NET. Xamarin is an abstraction layer that manages communication of shared code with underlying platform code. Xamarin runs in a managed environment that provides conveniences such as memory allocation and garbage collection.

Xamarin — Single Code Base for iOS, Android and Windows Applications

Xamarin applications can be written on PC or Mac and compile into native application packages, such as an .apk file on Android, or an .ipa file on iOS.

C# and XAML

  • Xamarin is a platform to create multi-OS apps
  • It allows you to create a single application, that can work across iOS, Android and Windows phone.
  • In order to develop these applications, you use C# and XAML.
  • XAML acts as the markup and data binding language for the phone app, and C# acts as the server side language.

3) How Xamarin Works

Xamarin allows developers to develop native applications for Android, iOS and Windows Phone platforms, with a single codebase, i.e. C# and a single IDE, i.e. Visual Studio . Thus, a developer can be able to develop native mobile applications without knowing Java, Kotlin, Objective-C or Swift. What that means is, all the C# code has to be converted to make it working on these three separate platforms.

Xamarin Promises:

  • Xamarin provides native UI interface.
  • Xamarin provides native API access.
  • Xamarin provides native performance.

Xamarin-Forms Architecture

Xamarin allows you to create native UI on each platform and write business logic in C# that is shared across platforms. In most cases, 80% of application code is sharable using Xamarin.

Xamarin takes care of translating or compiling all your C# code to its corresponding platform-specific code

Xamarin is built on top of Mono, an open-source version of the .NET Framework based on the .NET ECMA standards.

Mono has existed for almost as long as the .NET Framework itself, and runs on most platforms including Linux, Unix, FreeBSD, and macOS. The Mono execution environment automatically handles tasks such as memory allocation, garbage collection and interoperability with underlying platforms.

Xamarin Forms Architecture

Xamarin.Android Architecture

For Android, Xamarin leverages the JIT(Just In Time) compilation to create an optimized executable.

Xamarin.Android applications run within the Mono execution environment. This execution environment runs side-by-side with the Android Run Time(ART) virtual machine.

Both runtime environments run on top of the Linux kernel and expose APIs to the code that allows access to the underlying system.

Xamarin.Android applications also contain the Android Callable Wrappers(ACW) to allow Android to call into managed code.

Managed Callable Wrappers(MCW) are used whenever managed code needs to call into Android APIs.

Diagram of Mono and ART above the kernel and below .NET/Java + bindings

Xamarin.iOS Architecture

For iOS, Xamarin provides a fully compiled (AOT — Ahead Of Time) binary that directly runs on your device to provide native performance.

Xamarin.iOS exposes a C#/CIL binding to the Cocoa Touch API and also provides access to ECMA CIL APIs and various other .NET APIs.

Xamarin.iOS runs within the Mono execution environment and uses full AOT compilation to compile C# code to assembly language. This runs side-by-side with the Objective-C runtime. Both runtime environments run on top of a UNIX-like kernel, specifically XNU, and expose various APIs to the user code allowing developers to access the underlying native or managed system.

Xamarin.iOS instead uses an Ahead of Time (AOT) compiler to compile the managed code. This produces a native iOS binary, optionally optimized with LLVM for devices, that can be deployed on Apple's ARM-based processor.

4) System Requirements

MacOS Requirements

  • Operating SystemmacOS Mojave (10.14)
  • Development Environment — Visual Studio for Mac
  • Xamarin.iOS — Yes and iOS 12 SDK recommended
  • Xamarin.Android — Yes and Android 6.0 / API level 23 recommended
  • Xamarin.Forms — (Both iOS and Android) — Xamarin.Forms apps built on macOS can include iOS, Android, and macOS projects, subject to the SDK requirements above. Xamarin.Forms projects for Windows/UWP cannot be built on macOS
  • Xamarin.Mac — Yes and macOS Mojave (10.14) SDK recommended

Windows Requirements:

  • Development Environment — Visual Studio
  • Xamarin.iOS — Yes (with Mac )
  • Xamarin.Android — Yes
  • Xamarin.Forms — Android, Windows/UWP (iOS with Mac computer)
  • Xamarin.Mac — Open project & compile only

5) To be proficient in Xamarin, you need to learn

  • C# language: It's a very easy language to learn and you don't need to master it anyway. It shouldn't take long.
  • Mobile development: Start with one (iOS or Android). You will need to understand how the platform works, how to use controllers, how to store files on the device, how to use all the great features of a smartphone. It's a never-ending path but even getting the basics right takes a long time and is hard.
  • Architecture: to get the most out of Xamarin, you will want to share as much code as possible and architecture your code & solution right. It is much harder than having a single application or two different codebase for iOS & Android (even though it's much better in the long term). A good start is deeply understanding POO and patterns such as MVC & MVVM.

6) The Pros of Choosing Xamarin

Here are some of the biggest advantages to choosing Xamarin:

  • A single tech stack for faster development — Created with Visual Studio, Xamarin-based apps are developed using a single language: C#. Xamarin apps utilize C# and shared codebases that cover up to 90% of each platform's particular language, APIs and data structure and wrap them in a .NET layer that enables cross-platform development. By developing in C# and allowing Xamarin to handle cross-platform implementations, development teams will be able to accomplish much more with less.
  • Rapid prototyping: With Xamarin.Forms, developers have access to a complete cross-platform UI toolkit to build interfaces that work on any device. This allows for the creation of a single user interface across all devices, enabling developers to share more code without having to modify the UI for every platform.
  • Native performance and user experience: In Xamarin it is possible to access each and every native API, so it is possible to use completely native UI, Bluetooth, SDKs etc. Because Xamarin can take full advantage of system- and hardware-specific APIs, apps built using the software will run as well as apps compiled in each platform's preferred language. Users won't be able to tell the difference between your app and a native app because there isn't one.
  • Native performance and user experience: In Xamarin it is possible to access each and every native API, so it is possible to use completely native UI, Bluetooth, SDKs etc. Because Xamarin can take full advantage of system- and hardware-specific APIs, apps built using the software will run as well as apps compiled in each platform's preferred language. Users won't be able to tell the difference between your app and a native app because there isn't one.
  • Reduced time to market: Building apps with shared codebases eliminates time that would typically be spent translating, rewriting or recompiling code to work on different platforms. This shaves weeks, months and possibly years off of the development cycle, allowing apps for all three major platforms to be developed simultaneously. And because these apps are being built together, it means feature parity won't slowly trickle down from your most popular platform to your least — they'll be ready for deployment to all of your platforms at once.
  • Less maintenance: Maintaining and updating apps built using Xamarin requires less work. Once you've made changes to our source file, they can be applied directly to your apps, eliminating the need to update the source code of your apps individually should any updates, bug fixes or new features become necessary.
  • Apps for all platforms: What happens if you've got a killer desktop app that needs a mobile version or vice-versa? With Xamarin, it's no problem — developers can create apps for mobile and desktop experiences simultaneously. This also helps development teams cut back on having to decide whether to develop for just one single platform, as Android, iOS and Windows can be handled simultaneously.
  • Easy to keep updated. Xamarin takes advantage of native frameworks and usually it takes 1–3 days for iOS and Android platforms to catch up to the latest features. Which is why new platform-specific features can be promptly introduced to your app once Xamarin has been updated.

7) The Cons of Choosing Xamarin

  • It's expensive for enterprises. Xamarin is free for individuals and small companies, however, enterprises need to purchase a license for Microsoft's Visual Studio. For bare-bones access to Visual Studio without advanced Azure DevOps features or cloud services, single-user licenses start at $499. Enterprise users requiring all the bells and whistles pay up to $2,999 for an annual subscription to Visual Studio Enterprise.
  • Complicated to use all open-source libraries. While Xamarin does support most of .Net libraries, it doesn't support all of the available 3rd-party libraries for Android and iOS without specific wrappers.
  • Not suitable for apps with heavy graphics. Each platform has a different method for visually laying out screens.If the application has rich UX/UI, it should be implemented natively.
  • Larger App Size. Xamarin adds 3–5 megabytes for the release and around 20 megabytes for debug builds.

8) Xamarin Comparison with other Cross platforms(Xamarin vs Flutter vs React NativeApp )

Speed:

App speed is always a concern for the app owners so it has to be quick and responsive. Flutter offers faster app development with faster app speed at the output. Other platforms like React Native and Xamarin also performs better in the app speed but whilst comparing with the Flutter they are slightly slower. The app speed also depends on the development process, functions, features, and other terms so it's hard to compare on the instant but we can conclude the Flutter as a faster cross-platform app development framework.

Community Support:

Community support is built to give support and point out any issues related to the framework. While talking about community support, Xamarin lost in the competition because it has limited community support. On the other hand, React Native and Flutter have a better community for solving any issues and make it better for the users. According to the GitHub, React Native has more stars and Followers compare to the Flutter. So we can say React Native is the clear winner in terms of community supports.

Security:

Security of the source code and application is a must thing that's why security is listed in the priority action for all cross-platform developers. As mentioned earlier, React Native support third-party plugins and not have robust security supports. React Native lose the race of security, so let's talk about other cross platforms. Flutter and Xamarin based apps are robust and compatible with security access.

Customization:

As we know the React Native allows third-party plugins that simply means customization with the React Native is easy and compatible with Flux. Flutter's Hot Reload feature and Xamarin Live Reload feature empower both platform for live changes in the on-going development. Flutter and Xamarin have pre-install layout elements that simply indicates the freedom of customization with both cross-platform app development.

Usability By Developers:

The Xamarin is based on the C# that is simple and easy to learn the language. Flutter works on the Dart, an object oriented programming which is also easy to learn for newbie developers. React Native coded in Java that is most widely used in any development so working on Java is a piece of cake for every developer. In the concise, Xamarin and React Native are the easiest to access cross-platform app development framework.

Popularity:

According to Xamarin, the cross-platform tool is used by over 1.4 million developers worldwide. Moreover, Xamarin products are used by over 15,000 companies from over 120 countries in different industries such as media, transportation, finance, healthcare, and gaming. Due to its ability to write native UI code for app development, many popular brands use the Xamarin for crafting their application. Xamarin develops native codes but it is not free, so it is considered for the premium users. As most of the developers use Xamarin but still many developers rely on the Flutter and React Native.

Popular Apps that used React Native, Xamarin and Flutter

React Native Platform

  • Walmart
  • SoundCloud
  • Bloomberg
  • FaceBook
  • Instagram

Xamarin Platform

  • Storyo
  • SuperGiant Games
  • The World Bank
  • APX
  • Skulls of the Shogun

Flutter Platform

  • Alibaba
  • Hamilton Musical
  • Google AdWords
  • AppTree
  • Google Greentea

9)Why Choose Xamarin for App Development over React Native & Flutter?

Xamarin is equipped with robust emulators that suit various mobile platforms, and this is an important reason why many business organizations are relying on this cross-platform app development framework. Xamarin provides Several options for debugging with the freedom to crosscheck from the desktop, emulator, or directly on the device. Here are some of the noteworthy features of this framework that developers are enjoying.

  • Performance: The performance level of apps is highly competitive compared to hybrid or any other cross-platform development tools. Image loading is 14% faster when compared to other platforms, and image-saving speed is super-fast as well.
  • Development Speed: Xamarin comes with a library of templates that permits to use of standard interface elements. Developers enjoy when the inception to development speed is faster with Xamarin.
  • Sharable Code: Developers are equipped with the feature to write C# code that can run on cross-platforms. PCL (Portable Class Libraries), Shared Projects, .Net Standard Libraries facilitate code sharing. Adding more value to this feature, the Xamarin.forms framework makes it possible to share the same code on several other platforms.
  • Native UX: It is compatible with different operating systems and enables developers to achieve native look whether they develop the app for Android or iOS.
  • Open Source: Xamarin is an open-source free tool that comes with Microsoft's development environment Visual Studio. It gives you the freedom to use built-in tools for manual customization along with an option to reuse the codes.
  • Resourceful: Developers can go in-depth if they want to understand how exactly the platform works. Xamarin is owned by Microsoft and the platform is focused on simplifying the cross-platform app development process.

Xamarin comes with a compilation of tools like Xamarin.mac, Xamarin.insights and Xamarin.testcloud.

It gives you full freedom to create Mac Apps, analyze apps through Insights and run automated tests with the Xamarin test cloud.

10) Why Xamarin Is a Win?

If you're a developer showing any inkling of needing apps developed for multiple platforms, Xamarin is one of the best tools available to make your life easier.

Xamarin comes with a range of rich features. Coupled with an ever-growing community of developers, it has become a personal favourite of experienced and new developers alike when it comes to using a cross-platform development framework.

Thanks to Xamarin's powerful C# environment, native and cross-platform libraries and APIs, and ease of deployment, it's the best choice to keep Android, iOS and Windows apps developed in sync. This, in turn, reduces the overall time of development and brings new features to your users faster.

The approach is as simple as write once run anywhere. You can skip the development stages during tight deadlines.The community is expected to receive a lot of application updates from Xamarin.

Enterprises can adopt this framework because it doesn't require native iOS and Andriod platforms.This tool can extend the app development to the next level and is easily accessible.

Xamarin is designed to scale up and is open-source, and for many businesses, this cross-platform framework has become an obvious choice.

Let's connect!

You can find me on Twitter | LinkedIn | GitHub

What Is Xamarin and How Does It Work

Source: https://medium.com/a-developer-in-making/everything-you-need-to-know-before-starting-xamarin-development-2019-edition-49744616196e