Book Image

Mastering Cross-Platform Development with Xamarin

By : Can Bilgin, Miljenko Cvjetko, Paulo Ortins, Robert Hellestrae, Craig Dunn
Book Image

Mastering Cross-Platform Development with Xamarin

By: Can Bilgin, Miljenko Cvjetko, Paulo Ortins, Robert Hellestrae, Craig Dunn

Overview of this book

The main goal of this book is to equip you with the required know-how to successfully analyze, develop, and manage Xamarin cross-platform projects using the most efficient, robust, and scalable implementation patterns. This book starts with general topics such as memory management, asynchronous programming, local storage, and networking, and later moves onto platform-specific features. During this transition, you will learn about key tools to leverage the patterns described, as well as advanced implementation strategies and features. The book also presents User Interface design and implementation concepts on Android and iOS platforms from a Xamarin and cross-platform perspective, with the goal to create a consistent but native UI experience. Finally, we show you the toolset for application lifecycle management to help you prepare the development pipeline to manage and see cross-platform projects through to public or private release.
Table of Contents (19 chapters)
Mastering Cross-Platform Development with Xamarin
About the Authors
About the Reviewers


Although it was initially born as a community effort to port the .NET libraries and common language runtime compilers to various operating systems, the Xamarin product suite soon became the common ground to develop applications for Android and iOS operating systems using the .NET framework and the most popular CLR language, C#. The emergence of the Xamarin development platform created a new development niche, serving products to a variety of platforms at the same time while letting users adapt their existing .NET development skills to these new platforms and produce applications for a wider range of devices and operating systems. Thanks to Xamarin, developers are now enjoying a new era where development efforts don't target only a single application platform, but span multiple devices including smart phones, tablets, personal computers, and even wearable devices, creating highly efficient native applications.

What this book covers

Chapter 1, Developing with Xamarin, provides an insightful look at the Xamarin framework and architecture on target platforms. It also includes introductory information and tips on preparing the development environment for Xamarin.

Chapter 2, Memory Management, investigates how memory is managed on iOS and Android with Xamarin runtime. While drawing parallels with .NET platform, it provides examples of pitfalls, patterns, and best practices.

Chapter 3, Asynchronous Programming, dives deep into asynchronous and multi-threaded programming concepts. Platform-specific problems in various threading scenarios on different platforms are discussed.

Chapter 4, Local Data Management, provides useful patterns and techniques to efficiently use, manage, and roam data on mobile devices using Xamarin.

Chapter 5, Networking, contains a detailed look at the networking capabilities of Xamarin applications and various service integration scenarios. Networking implementations are illustrated with real-world examples, including the use of local storage for data caching.

Chapter 6, Platform Extras, concentrates on platform-specific APIs and features. It explains some of the peripherals that can be employed in Xamarin applications. A look at native libraries and how to include them in cross-platform Xamarin applications is also included in this chapter.

Chapter 7, View Elements, provides introductory information about UX (User Experience) and design concepts, and an explanation of the differences and similarities between design principles on Xamarin platforms.

Chapter 8, Xamarin.Forms, focuses on the various features and extensibility options of Xamarin. It also covers the forms extension module and how to use it to generate consistent user interfaces on multiple platforms.

Chapter 9, Reusable UI Patterns, discusses the strategies and patterns for reusing visual assets in cross-platform projects. Some advanced software architectural topics about MVC and MVVM patterns are also analyzed and demonstrated.

Chapter 10, ALM – Developers and QA, provides an introduction to Application Lifecycle Management and continuous integration methodologies for Xamarin cross-platform applications. As the part of the ALM process that is the most relevant to developers, unit testing strategies are discussed and demonstrated, as well as automated UI testing.

Chapter 11, ALM – Project and Release Management, explains the essentials of version control and automated continuous integration workflows. Source control options, as well as automated build strategies for Xamarin projects, are demonstrated.

Chapter 12, ALM – App Stores and Publishing, explains the processes related to app package preparation and release, which constitutes the last step of the application lifecycle.

What you need for this book

In order to build the sample project and make use of the code samples in this book, you will need a Xamarin.iOS and/or Xamarin.Android subscription, depending on the platform you want to target. Most of the diagnostic tools used are distributed as part of the development SDKs for the target platforms. As a development IDE, you will need Visual Studio 2013 (or higher) or Xamarin Studio if you are using or configuring a Windows based development environment, but only Xamarin Studio otherwise. For testing and diagnostics, real mobile devices or SDK-provided emulators can be used.

Who this book is for

This book is ideal for those who want to take their novice or intermediate-level Xamarin mobile development skills to the next level to become the go-to person within their organization. To fully understand the patterns and concepts described, you should possess a reasonable level of knowledge and an understanding of the core elements of cross-platform application development with Xamarin.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "For instance, Objective-C types such as NSObject, NSString, NSArray are exposed in C# and provide binding to underlying types."

A block of code is set as follows:

namespace Master.Xamarin.Portable
    public class MyPhotoViewer
        private readonly IStorageManager m_StorageManager;

Any command-line input or output is written as follows:

bcdedit /copy {current} /d "No Hyper-V"
bcdedit /set {<identifier from previous command>} hypervisorlaunchtype off

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "It can still be accessed using the Run with Mono HeapShot menu item under the Project menu in Xamarin Studio."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows

  • Zipeg / iZip / UnRarX for Mac

  • 7-Zip / PeaZip for Linux


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.