Cookies icon

This website uses cookies to ensure you get the best experience on our website.

Top 10 questions about Xamarin
by Artur Pawlos

Posted on

Top 10 questions about Xamarin

Xamarin has been on the market for some time. It is becoming more and more popular, however not everyone knows what it is and what function it serves. In this post, I will share the 10 most common questions about Xamarin. I hope that everyone who reads this article will get some new information about this technology.

  1. What is Xamarin?

Xamarin is a programming platform for mobile applications which allows you to create both Android and iOS applications (I will skip Windows Phone because it has practically disappeared from the market) using C# and the .NET framework. You can develop them in Visual Studio (also available on macOS). There are two approaches to do that: Xamarin.Native or Xamarin.Forms.

  1. What is Xamarin.Forms and Xamarin.Native?

Xamarin.Forms - strongly promoted by Microsoft and uses shared business logic and interface (views) written once for all platforms using XAML.

Xamarin.Native - shared C# code for business logic but interface must be written separate for each platform. Xamarin.Native is mapping Android and iOS APIs in a 1:1 ratio so everything for Google and Apple will be shared. This is very important because thanks to this functionality, we can easily acquire new knowledge. If we do not know how to implement something, we can refer directly to the official documentation and translate the examples from Objective-C or Java into C#.

  1. What to choose? Xamarin.Forms or Xamarin Native?

 You should answer some questions:

  • What type of project is it? Are you creating a corporate or social application?

Social applications should be done in Xamarin.Native because they require a large styling/customization (a social application must have a "nice" appearance, so people want to use it). If we would like to write such an application in Xamarin.Forms, we have to improve the appearance by creating a ”Custom Renderer” which would be more difficult and would also take more time.

However, Xamarin.Forms is a good choice when we are creating business applications which most often contain: lists, details of elements, or forms for entering data.

When we do not have a rich UI, Xamarin.Forms works great and provides many ready-made components.

  • Which developers will create the application?

If we want to create a Xamarin.Native application, the programmer should know the platforms that the application will support. So if we develop an application for Android and iOS, the programmer should know the specifics of both of these platforms. However, if the programmer knows UWP or WPF, it will be easier for him to create applications using Xamarin.Forms.

  • What is the complexity of the project?

If the app consists of a small number of views and you need to customize them, it's worth doing it in Xamarin.Forms. If it has a lot views and is complicated, Xamarin.Native is a better choice.

  1. Which platforms does Xamarin support?

Xamarin Native runs across iOS and Android.

Xamarin.Forms runs across iOS, Android, and Windows Phone. Recently, Tizen is also supported (by using Visual Studio Tools for Tizen).

Tizen is a Linux-based open-source OS running on over 50 million Samsung devices including TVs, wearables, and mobile phones.

  1. How about performance?

Xamarin.Native has very similar performance to applications created by Java or Objective-C/Swift and end users probably wouldn’t notice a difference. Unfortunately, Xamarin.Forms is a different story, and worse performance can be noticed (e.g. initialization time). You should consider whether this will be a problem for your end user.

  1. Do we need a mac to compile/develop iOS code?

Yes, we will need a mac to compile the application for the Apple platform.

Using iOS Simulator, we can display iOS emulator directly on a computer with Windows (the iOS code is compiled on a Mac by the so-called Xamarin Mac Agent, which connects from Windows to Mac). Unfortunately, this option is available only for Visual Studio Enterprise. If we cannot afford to buy a license, then we must test the iOS application directly on a Mac.

  1. Which code strategy should I use? Shared project or Portable Class Library?

If we decided to use Xamarin technology we have to make a decision between two code strategies: Shared project or Portable Class Library. The first option creates a Shared Asset Project(SAP) consisting only of shared code files while the second creates a Portable Class Library. With the PCL approach, all the common code is bundled into a dynamic-link library that each application project references and binds to at run time.

With the SAP approach, the common code files are effectively included with each of the application projects at build time.

Personally, I use the PCL approach because this solution allows creating more "clear” code. It provides a clear division of code in the application, increases the transferability of solutions, and allows programmer to build libraries with specific code for specific systems. This code can then be loaded using dependency injection.

However, many programmers use Shared Project. You have to choose which option will be better for you.

  1. Is there designer support in Xamarin.Native?

Yes, both Xamarin.Android and Xamarin.iOS supports designer.

Xamarin.Android supports the declarative style of user interface design based on XAML files and a programmatic user interface creation in code. When using the declarative approach, XAML files can be either hand-edited or modified visually by using the Xamarin.Android designer. Use of a designer allows instant feedback during UI creation.

Xamarin.iOS also have designer for the iOS storyboard and Interface Builder. Additionally, it supports advanced features such as custom controls that render at design-time in the editor.

  1. Do I have to create iOS and Android projects at the same time?

No. You can focus on creating a project only for one platform - Android for example and if you will need to have the application also available on iOS in the future, you can add an iOS project to your existing solution.

All you have to do is create a cross-platform compatible project type such as Shared Library or Portable Class Library and include the code you would like to eventually run across both platforms in that project

  1. How about testing?

Xamarin provides two basic tools for conducting automated tests. The first of these is framework for writing UI tests (Xamarin.UITest). It allows the possibility to write code that emulates user behavior and allows you to test on an emulator or physical device that is connected to a computer.

The second tool is Visual Studio App Center (the next generation of Xamarin Test Cloud) which allows you to perform a previously written test in the cloud on more than 2000 physical devices.

Leave a comment

Last posts