Why using Xamarin for cross-platform development

Coding Mobile Xamarin

Why using Xamarin for cross-platform development

“Everything you need to deliver great mobile apps” is Xamarin’s premise

 

It’s a fact: individuals who are developing apps for a wide variety of industries are using this amazing software. Some firms such as JetBlue, Dutch Tax Office, Skulls of the Shogun game and McKesson are the perfect example to show how apply Xamarin to many different businesses and contexts.

During the last few years in UruIT, we have been developing cross platform mobile apps in an agile and efficient way. This has allowed us to create excellent user experience. Frameworks such as Ionic, Sencha Touch, and JQuery Mobile, along with wrappers like PhoneGap, have been successful to work with. However, we have realized that Xamarin is a step ahead.

Ever since Microsoft acquired Xamarin, the software is increasing its popularity, and also improving in many ways. Significant changes of tools, controls, and components, are happening continuously. With the aim of making existent and future apps work at their best.

 

The Xamarin world

Xamarin generates native applications for each mobile platform: Android, iOS and Windows Universal. We are able to do so thanks to the main libraries: MonoTouch y MonoDroid. Since they allow us to develop in C# and compile in native code.

It is also important to highlight that from our C# code, we have unlimited access to Apple’s iOS SDK and Android’s API, which prevents us from losing functionalities. Besides, we can integrate codes in Objective-c language for iOS and Java for Android projects.

It takes a lot more than just code-generating tools in order to create great apps. The need for good quality and support strategies are very important. In order to ensure a great design, performance and behavior on as many devices, platforms and fabricants as possible. Therefore, Xamarin’s products (including Test Cloud and Insights) offer an end-to-end solution in order to create high quality multi-platform compilations, tests, and follow ups.

 

Let’s expand a bit on these two concepts:

There are 2 ways to implement this solution: One of them is traditional Xamarin (for Android and iOS), and the other one is Xamarin Forms. The latter one, which is more recent, has been exponentially growing. Not only does it share logic, as in all Xamarin projects, but also has the advantage of being able to share the User Interface (UI).

Xamarin

This traditional tool, is utilized to generate native apps on Android and iOS. However, instead of creating them in their most common languages (Java in Android Studio, and Objective-C in xCode), they are developed in C# in combination with the power of .Net Base Class Library (BCL).

Xamarin-sahred-code

If we are looking for the best performance, as well as a complete handle of each and every functionality within the OS, while utilizing a great amount of features from the original SDK, and similar to native UI design, the best option would be working with traditional Xamarin. Although we would need to generate a project for each platform, as well as having to develop based on different paradigms, this will give us the advantage of doing everything as if it was native. However, we have to take into consideration that we can share projects of logic in order to avoid duplicates.

 

With Xamarin you can achieve:

  • Native User Interface
  • Native Performance
  • Shared code across platforms
  • C# & .NET Framework
  • Full API Coverage

xamarin.iOS-xamarin.Android

Speaking of improvements, last April during the Evolve 16, some of the changes made on Xamarin have been announced. These are the ones I consider more relevant:

Remote Simulator Windows can now be used to run and test an iOS application. A simulator for iOS applications has been added, allowing us to stay on Windows simply by connecting a Mac to the net.

Usb remoting – You can deploy and/or debug an Iphone only by connecting it to the usb port on Windows.

Workbooks – It is a way of sharing information live while creating a variety of documents such as tutorials, trainings and experiments. Occasionally, it can be used as playground, since it has integration with some APIs. This allows us to render controls, maps, and colors, among other feature.

 

Xamarin.Forms

As previously mentioned, this kind of project allows us to have not only a single shared code between platforms (iOs, Android, and Windows apps), but also the UI. You can share the latter via Xaml files or by generating it from C# code. That way obtaining a customized design for each platform. After the launching of the second version, XF has significantly improved the reported bugs and added new controls. Thanks to these positive changes, XF has gain a reputation as a development tool for high complexity projects. In its library, we can find Pages, Layouts and Controls, as well as Two-way Data Binding, Navigation, Animation API, Dependency Service, and Messaging Center.

If we are looking to customize the platform, we can always apply logic to this specific project, as if we were working with traditional Xamarin. The UIs are rendered utilizing each platform’s native controls in order to keep the look and feel of each OS.

code-sharing2x

xaamrin-shared-c#-app-logic

Some changes

As previously mentioned, ever since XF released the 2.x version, and also since Evolve 16, there have been many improvements, as well as the addition of some controls, styles and extensions, in order to be able to develop in a faster and easier way. Some of the most important changes are the following:

  • Design Preview (UI) – Before XF, we couldn’t look at the changes in real time when working on a design with a Xaml file. Fortunately, since the creation of tools such as Gorilla Player, we were able to see our Xaml. However, it was not completely integrated to our IDE, and thus, we could not use it easily.
  • Data Pages It is a minimalist container that can be loaded with data from a Cloud Datasource or json.
  • Themes – It allows us to define a specific theme in order to control the style of each of our controls, containers, etc. Light theme and Dark theme are predefined. However, you can create customized themes.
  • Embedded Platform – (Stable) It allows us to add our own customized controls to our XF project in one line, without the need of customizing the render.
  • Url navigation – Uses the search engines on mobile devices in order to come up as a recommended result and automatically open the App. This is not only an advantage for the app’s competitive ranking, but also for the user-app connection experience.
  • XAML Power Toys – (Stable) It is an extension that allows to quickly create a data-bound and data entry forms from a viewmodel or entity class.

We have tested the above mentioned additions and they seem very promising. Therefore, we are now waiting for the final release of those that are pending. Some of them are known and work with stable versions, however, they have been mentioned:

  • XAML pre-compiled
  • Android Material Design
  • iOS9 support
  • New gesture application 

 

Xamarin Solutions

Based on previous experiences, we can say that a 70% of the code is shared. This percentage increases to a 85% approximately, if we use Xamarin Forms. You can use the remaining code for specific functionalities such as accessing the camera. In these particular cases, a specific code has to be applied to each project.

These days, there is a constantly increasing demand for mobile applications. It is common knowledge that apps with a lack of emphasis on user experience tend to be unsuccessful. Therefore, a need for native applications, with good quality, high performance, and amazing UX, is rapidly increasing in order to be competitive in the market.

Xamarin Solutions is a great tool for mobile development. It has the power to create either simple or complex native apps, in a short period of time, and with one development team only.

Get to know more about how Xamarin helped our team to improve performance in record time in this link.

Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn
Sebastian Cabrera

Sebastian Cabrera

Sebastian has +7 years of experience in the IT field, working mostly in software development with Microsoft technologies and +3 years of experience applying agile methodologies. In the last two years, he has been focused on mobile development, using Sencha Touch, Xamarin Forms, Xamarin iOS and Xamarin Android. During his last projects he has been involved with Mobile DevOps in order to be able to cover all aspects of apps delivery life cycles.

Liked this post?

Get more fresh content like this