Book Image

Xamarin.Forms Projects

By : Johan Karlsson, Daniel Hindrikes
Book Image

Xamarin.Forms Projects

By: Johan Karlsson, Daniel Hindrikes

Overview of this book

Xamarin.Forms is a lightweight cross-platform development toolkit for building applications with a rich user interface. In this book you'll start by building projects that explain the Xamarin.Forms ecosystem to get up and running with building cross-platform applications. We'll increase in difficulty throughout the projects, making you learn the nitty-gritty of Xamarin.Forms offerings. You'll gain insights into the architecture, how to arrange your app's design, where to begin developing, what pitfalls exist, and how to avoid them. The book contains seven real-world projects, to get you hands-on with building rich UIs and providing a truly cross-platform experience. It will also guide you on how to set up a machine for Xamarin app development. You'll build a simple to-do application that gets you going, then dive deep into building advanced apps such as messaging platform, games, and machine learning, to build a UI for an augmented reality project. By the end of the book, you'll be confident in building cross-platforms and fitting Xamarin.Forms toolkits in your app development. You'll be able to take the practice you get from this book to build applications that comply with your requirements.
Table of Contents (11 chapters)

Xamarin and Mono

Xamarin is a developer platform that is used for developing native applications for iOS (Xamarin.iOS), Android (Xamarin.Android), and macOS (Xamarin.Mac). It is technically a binding layer on top of these platforms. Binding to platform APIs enables .NET developers to use C# (and F#) to develop native applications with the full capacity of each platform. The C# APIs we use when we develop applications with Xamarin are more or less identical to the platform APIs, but they are .NETified. For example, APIs are often customized to follow .NET naming conventions, and Android set and get methods are often replaced by properties. The reason for this is that APIs should be easier to use for .NET developers.

Mono (https://www.mono-project.com) is an open source implementation of the Microsoft .NET framework, which is based on the European Computer Manufacturers Association (ECMA) standards for C# and the common language runtime (CLR). Mono was created to bring the .NET framework to platforms other than Windows. It is part of the .NET foundation (http://www.dotnetfoundation.org), an independent organization that supports open development and collaboration involving the .NET ecosystem.

With the combination of Xamarin platforms and Mono, we will be able to use both all platform-specific APIs and all platform-independent parts of .NET, including, for example, namespaces, systems, System.Linq, System.IO, System.Net, and System.Threading.Tasks.

There are several reasons to use Xamarin for mobile application development, as we will see in the following sections.

Code sharing

If there is one common programming language for multiple mobile platforms, and even server platforms, then we can share a lot of code between our target platforms, as illustrated in the following diagram. All code that isn't related to the target platform can be shared with other .NET platforms. Code that is typically shared in this way includes business logic, network calls, and data models:

There is also a large community based around the .NET platforms and a wide range of third-party libraries and components that can be downloaded from NuGet (https://nuget.org) and used across the .NET platforms.

Code sharing across platforms will lead to shorter development times. It will also lead to applications of a higher quality because we only need to write the code for business logic once. There will be a lower risk of bugs, and we will also be able to guarantee that a calculation will return the same result, no matter what platform our users are using.

Using existing knowledge

For .NET developers who want to start building native mobile applications, it is easier to just learn the APIs for the new platforms than it is to learn programming languages and APIs for both old and new platforms.

Similarly, organizations that want to build native mobile applications could use their existing developers with their knowledge of .NET to develop applications. Because there are more .NET developers than Objective-C and Swift developers, it would be easier to find new developers for mobile application development projects.