Xamarin: Building Native Mobile, Mac and Windows Apps in C#

by Sysco LABS Articles 4 November 2016

In this Innovation Session, Anuradha Wickramarachchi, Mithila Wickramarathne, Vijini Mallawaarachchi and Dimuthu Kariyawasam from CAKE Connect talk about the methodology of building native mobile, Mac and Windows apps in C# using Xamarin. Xamarin is a cross-platform implementation of the Common Language Infrastructure (CLI) and Common Language Specifications (often called Microsoft .NET). Xamarin was released in February 2013 as Xamarin.Android and Xamarin.iOS making it possible to do native Android, iOS and Windows development in C#, with either Visual Studio or Xamarin Studio. Developers re-use their existing C# code, and share significant code across device platforms. Xamarin has made quite a splash in the tech industry by making apps for several well-known companies including 3M, AT&T, HP, and Target. Xamarin integrates with Visual Studio, Microsoft’s IDE for the .NET Framework, extending Visual Studio for Android and iOS development.


Why C#?

Mobile app development uses silo approaches. An information silo is an insular management system incapable of reciprocal operation with other, related information systems. The Mono network already has a large developer base, and anything you can do in Java or Objective-C, can also be done in C#. In C#, there are also more variables, and less typing. C# also has stronger types and smarter tools such as when using collections (with Generics). C# also provides language-level asynchronous programming support.


How Does Xamarin Work?

Xamarin offers two commercial products; Xamarin.iOS and Xamarin.Android. On iOS, Xamarin’s Ahead-of-Time (AOT) Compiler compiles Xamarin.iOS applications directly to native ARM assembly code. Xamarin.iOS can access any iOS SDK API as well as invoke Objective-C code using C#. Xamarin.iOS is used to build apps for the Apple watch platform and provides same day support for the latest OS builds by Apple. On Android, Xamarin’s compiler compiles down to Intermediate Language (IL), which is then Just-in-Time (JIT) compiled to native assembly when the application launches. Xamarin.Android has access to any Android SDK API, and can invoke Java code using C#. Xamarin.Android is used to build apps for Android wear and is up-to-date with the latest release of Android. Xamarin.iOS and Xamarin.Android are ideal for apps that require native behavior which needs accessibility to many platform-specific APIs.

Xamarin Forms are used by developers to create native user interfaces and share them across multiple platforms such as Android, iOS and Windows from a single shared C# codebase. The UI can be created in C# or XAML. At runtime, it is mapped into native UI elements. Xamarin Forms are ideal for apps that require little platform specific functions, and when code sharing is more important than custom UIs.


The Mobile Software Development Lifecycle

The lifecycle of a mobile software application is no different than the SDLC for web or desktop applications, it follows a five-step cycle of Inception, Design, Development, Stabilization and Deployment. In the Inception stage, the idea is refined and conceptualized to form a solid basis for the application. Major considerations that need to be taken into account at this stage are the competitive advantage the app will have, as well as infrastructure Integration, value and mobility of the app. The Design stage is where the UI/UX will be developed, defining how the app looks like. The coding of the app begins during the Development phase, where the idea is developed to a working prototype. The significant stages in this phase which the product will be developed are the prototype, alpha, beta and the final release candidate. Xamarin Profiler is used here for profiling.


Xamarin Studio

Xamarin Studio is a modern, sophisticated IDE with many features for creating Xamarin.iOS, Xamarin.Mac, Xamarin.Android and Xamarin Forms applications. It includes a rich editor, debugging, native platform integration with iOS, Mac and Android, and integrated source control to name just of few of its many features such as;

  • Complete Binding for the underlying SDKs
  • Objective-C, Java, C, and C++ Interoperability
  • Modern Language Constructs
  • Amazing Base Class Library (BCL)
  • Modern Integrated Development Environment (IDE)
  • Mobile Cross Platform Support

Xamarin Studio allows storyboards to be directly edited, including adding handlers without switching to Xcode. View controllers are controls that create a pixel-perfect representation of screens as they will appear when running on iOS devices, which makes it much more accurate than Xcode. Unlike Xcode’s Interface Builder, the Xamarin iOS Designer renders your custom views just as easy as it renders UIKit controls-live. It does not even touch a line of XML and allows preview layouts to be shown across multiple resolutions for various screens.

Leave a Comment