Book Image

Xamarin.Forms Projects - Second Edition

By : Daniel Hindrikes, Johan Karlsson
Book Image

Xamarin.Forms Projects - Second Edition

By: Daniel Hindrikes, Johan Karlsson

Overview of this book

Xamarin.Forms is a lightweight cross-platform development toolkit for building apps with a rich user interface. Improved and updated to cover the latest features of Xamarin.Forms, this second edition covers CollectionView and Shell, along with interesting concepts such as augmented reality (AR) and machine learning. Starting with an introduction to Xamarin and how it works, this book shares tips for choosing the type of development environment you should strive for when planning cross-platform mobile apps. You’ll build your first Xamarin.Forms app and learn how to use Shell to implement the app architecture. The book gradually increases the level of complexity of the projects, guiding you through creating apps ranging from a location tracker and weather map to an AR game and face recognition. As you advance, the book will take you through modern mobile development frameworks such as SQLite, .NET Core Mono, ARKit, and ARCore. You’ll be able to customize your apps for both Android and iOS platforms to achieve native-like performance and speed. The book is filled with engaging examples, so you can grasp essential concepts by writing code instead of reading through endless theory. By the end of this book, you’ll be ready to develop your own native apps with Xamarin.Forms and its associated technologies, such as .NET Core, Visual Studio 2019, and C#.
Table of Contents (13 chapters)

Xamarin platforms

The different Xamarin platforms available are Xamarin.iOS, Xamarin.Android, and Xamarin.Mac. In this section, we will take a look at each of them.

Xamarin.iOS

Xamarin.iOS is used to build apps for iOS with .NET and contains the bindings to the iOS APIs mentioned previously. Xamarin.iOS uses AOT compiling to compile the C# code into Advanced RISC Machine (ARM) assembly language. The Mono runtime runs alongside the Objective-C runtime. Code that uses .NET namespaces, such as System.Linq or System.Net, are executed by the Mono runtime, while code that uses iOS-specific namespaces are executed by the Objective-C runtime. Both the Mono runtime and the Objective-C runtime run on top of the X is Not Unix (XNU) Unix-like kernel (https://github.com/apple/darwin-xnu), which was developed by Apple. The following diagram shows an overview of the iOS architecture:

Xamarin.Android

Xamarin.Android is used to build apps for Android with .NET and contains bindings to the Android APIs. The Mono runtime and the Android Runtime (ART) run side by side on top of a Linux kernel. Xamarin.Android apps could either be Just-In-Time (JIT)-compiled or AOT-compiled, but to AOT-compile them, we need to use Visual Studio Enterprise.

Communication between the Mono runtime and ART occurs via a Java Native Interface (JNI) bridge. There are two types of JNI bridges—Manage Callable Wrapper (MCW) and Android Callable Wrapper (ACW). An MCW is used when code needs to run in ART and an ACW is used when ART needs to run code in the Mono runtime, as shown:

Xamarin.Mac

Xamarin.Mac is used to build apps for macOS with .NET and contains the bindings to the macOS APIs. Xamarin.Mac has the same architecture as Xamarin.iOS—the only difference is that Xamarin.Mac apps are JIT-compiled, unlike Xamarin.iOS apps, which are AOT-compiled. This is shown in the following diagram: