Book Image

Xamarin 4.x Cross-Platform Application Development - Third Edition

By : Jonathan Peppers
Book Image

Xamarin 4.x Cross-Platform Application Development - Third Edition

By: Jonathan Peppers

Overview of this book

Xamarin is a leading cross-platform application development tool used by top companies such as Coca-Cola, Honeywell, and Alaska Airlines to build apps. Version 4 features significant updates to the platform including the release of Xamarin.Forms 2.0 and improvements have been made to the iOS and Android designers. Xamarin was acquired by Microsoft so it is now a part of the Visual Studio family. This book will show you how to build applications for iOS, Android, and Windows. You will be walked through the process of creating an application that comes complete with a back-end web service and native features such as GPS location, camera, push notifications, and other core features. Additionally, you’ll learn how to use external libraries with Xamarin and Xamarin.Forms to create user interfaces. This book also provides instructions for Visual Studio and Windows. This edition has been updated with new screenshots and detailed steps to provide you with a holistic overview of the new features in Xamarin 4.
Table of Contents (19 chapters)
Xamarin 4.x Cross-Platform Application Development - Third Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Preface

Xamarin has built great products for developing iOS and Android applications in C#: Xamarin Studio, an addin for Visual Studio, Xamarin.iOS, and Xamarin.Android. Xamarin gives you direct access to the native APIs on each platform and the flexibility of sharing C# code.  Using Xamarin and C#, you get better productivity when compared to Java or Objective-C, and still retain great performance compared to an HTML or JavaScript solution.

 In this book, we will develop a real-world sample application to demonstrate what you can do with Xamarin technologies, and build on core platform concepts for iOS and Android. We will also cover advanced topics such as push notifications, retrieving contacts, using the camera, and GPS location. With Xamarin 3, a new framework was introduced called Xamarin.Forms. We will cover the basics of Xamarin.Forms and how you can apply it to cross-platform development. Finally, we will walkthrough what it takes to submit your application to the Apple App Store and Google Play.

What this book covers

Chapter 1Xamarin Setup, is a guide for installing the appropriate Xamarin software and native SDKs for doing cross-platform development. Directs Windows users on how to connect to a Mac on their local network for doing iOS development in Visual Studio.

Chapter 2, Hello, Platforms!, is a walkthrough of creating a simple calculator application on iOS and Android, which also covers some basic concepts on each platform.

Chapter 3, Code Sharing  between iOS and Android, is an introduction of code sharing techniques and project setup strategies that can be used with Xamarin.

Chapter 4, XamSnap - A Cross-Platform App, is an introduction to a sample application we will be building throughout the book. In this chapter we will write all the shared code for the application complete with unit tests.

Chapter 5, XamSnap for iOS, shows us how to implement the iOS user interface for XamSnap and cover various iOS development concepts.

Chapter6, XamSnap for Android, shows us how to implement the Android version of XamSnap and introduce Android-specific development concepts.

Chapter 7, Deploying and Testing on Devices, is a walkthrough the painful process of deploying your first application to a device. We also cover why it is important to always test your application on real devices.

Chapter 8, Contacts, Camera, and Location, introduces the library, Xamarin.Mobile, as a cross-platform way to access users’ contacts, camera, and GPS location and add these features to our XamSnap application.

Chapter 9, Web Services with Push Notifications, shows us how to implement a real backend web service for XamSnap using Windows Azure leveraging Azure Functions and Azure Notification Hubs.

Chapter 10, Third-Party Libraries, covers the various options of using third party libraries with Xamarin and how you can even leverage native Java and Objective-C libraries.

Chapter 11, Xamarin.Forms, helps us discover Xamarin's latest framework, Xamarin.Forms, and how you can leverage it to build cross-platform applications.

Chapter 12, App Store Submission, will walk us through the process of submitting your app to the Apple App Store and Google Play.

What you need for this book

For this book you will need a Mac computer running at least OS X 10.10. Apple requires iOS applications to be compiled on a Mac, so Xamarin has the same requirement. You can either use Xamarin Studio (best for Mac) or Visual Studio (best for Windows) as an IDE. Developers on Windows can work on iOS applications in Visual Studio by connecting to a Mac on their local network. Visit https://xamarin.com/download or https://visualstudio.com/download to download the appropriate software.

Who this book is for

This book is for developers that are already familiar with C# and want to learn mobile development with Xamarin. If you have worked in ASP.NET, WPF, WinRT, Windows Phone, or UWP, then you will be right at home using this book to develop native iOS and Android applications.

Conventions

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: "run asynchronous code in C# using the await keyword."

A block of code is set as follows:

class ChuckNorris
{
    void DropKick()
    {
        Console.WriteLine("Dropkick!");
    }
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

class ChuckNorris
{
    void DropKick()
    {
        Console.WriteLine("Dropkick!");
    }
}

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

# xbuild MyProject.csproj

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: "In order to download new modules, we will go to FilesSettings | Project Name | Project Interpreter."

Note

Warnings or important notes appear in a box like this.

Tip

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 [email protected], 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 www.packtpub.com/authors.

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 http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support 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

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Xamarin 4x-Cross-Platform-Application-Development-Third-Edition. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/Xamarin4xCrossPlatformApplicationDevelopmentThirdEdition_ColorImages.pdf.

Errata

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 http://www.packtpub.com/submit-errata, 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 https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

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 [email protected] with a link to the suspected pirated material.

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

Questions

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