Xamarin: Cross-Platform Mobile Application Development

Xamarin: Cross-Platform Mobile Application Development

Read it now on the O’Reilly learning platform with a 10-day free trial.

O’Reilly members get unlimited access to books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.

Book description

Master the skills required to develop cross-platform applications from drawing board to app store(s) using Xamarin

About This Book

Who This Book Is For

Mobile application developers wanting to develop skills required to steer cross-platform applications using Xamarin.

What You Will Learn

Developing a mobile application for just one platform is becoming a thing of the past. Companies expect their apps to be supported on iOS, Android and Windows Phone, while leveraging the best native features on all three platforms. Xamarin's tools help ease this problem by giving developers a single toolset to target all three platforms. The main goal of this course is to equip you with knowledge to successfully analyze, develop, and manage Xamarin cross-platform projects using the most efficient, robust, and scalable implementation patterns.

Module 1 is a step-by-step guide to building real-world applications for iOS and Android. The module walks you through building a chat application, complete with a backend web service and native features such as GPS location, camera, and push notifications. Additionally, you'll learn how to use external libraries with Xamarin and Xamarin.Forms. Module 2 provide you recipes on how to create an architecture that will be maintainable, extendable, use Xamarin.Forms plugins to boost productivity. We start with a simple creation of a Xamarin.Forms solution, customize the style and behavior of views for each platform. Further on, we demonstrate the power of architecting a cross-platform solution. Next, you will utilize and access hardware features that vary from platform to platform with cross-platform techniques. You will master the steps of getting the app ready and publishing it in the app store. The last module starts with general topics such as memory management, asynchronous programming, local storage, networking, and platform-specific features. You will learn about key tools to leverage the pattern and advanced implementation strategies. 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. After the completion of this course, you will learn a path that will get you up and running with developing cross-platform mobile applications and help you become the go-to person when it comes to Xamarin.

Style and approach

This course will serve as comprehensive guide for developing cross-platform applications with Xamarin with a unique approach that will engage you like never before as you create real-world cross-platform apps on your own.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased 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 code file.

Show and hide more Table of contents Product information

Table of contents

  1. Xamarin: Cross-Platform Mobile Application Development
    1. Table of Contents
    2. Xamarin: Cross-Platform Mobile Application Development
    3. Xamarin: Cross-Platform Mobile Application Development
    4. Credits
    5. Preface
      1. What this learning path covers
      2. What you need for this learning path
            1. Module 1:
            2. Module 2:
            3. Module 3:
            1. Downloading the example code
            2. Errata
            3. Piracy
            4. Questions
            1. 1. Setting Up Xamarin
              1. The Xamarin tools
              2. Installing Xcode
              3. Installing Xamarin
              4. Choosing a Xamarin license
              5. Setting up the Android emulator
              6. Enrolling in the iOS Developer Program
              7. Registering as a Google Play developer
              8. Summary
              1. Building your first iOS application
              2. Understanding Apple's MVC pattern
              3. Using the iOS designer
              4. Building your first Android application
              5. Android activities
              6. Xamarin's Android designer
              7. Summary
              1. Learning the MVVM design pattern
                1. Implementing MVVM in an example
                1. Setting up a cross-platform solution
                1. Using PCLs in Xamarin
                1. Starting our sample application concept
                2. Developing our Model layer
                3. Writing a mock web service
                4. Writing the ViewModel layer
                  1. Implementing our LoginViewModel class
                  2. Implementing our RegisterViewModel class
                  3. Implementing our FriendViewModel class
                  4. Implementing our MessageViewModel class
                  1. Setting up a new project for unit tests
                  2. Writing assertions
                  1. Understanding the basics of an iOS app
                  2. Using UINavigationController
                    1. Methods in Navigation Controllers
                    2. Setting up a Navigation Controller
                    1. Creating a LoginController class
                    2. Modifying the controller's layout
                    3. Registering and subscribing view models and services
                    1. Introducing Android Manifest
                      1. Setting up the Manifest
                        1. Common manifest permissions
                        1. Layouts and ViewGroups in Andorid
                        2. Implementing the login functionality
                        1. Implementing the conversations screen
                        2. Setting up the adapter
                        1. iOS provisioning
                          1. Prerequisites for deploying to iOS
                          2. Creating a provisioning profile
                          1. Garbage collector
                          2. Memory leaks
                          3. Accessing objects disposed by GC
                          1. Learning Windows Azure
                          2. Setting up your Azure account
                          3. Exploring Azure Mobile Services
                          4. Creating tables and scripts
                          5. Adding a backend to XamChat
                            1. Adding the Azure Mobile Services NuGet package
                            1. Setting up proper provisioning
                            2. Setting up your provisioning profile
                            3. Setting up a certificate signing request
                            4. Making client-side changes for push notifications
                            1. The Xamarin Component Store
                              1. The most common components
                              1. Working with Objective Sharpie
                              1. Introducing Xamarin.Mobile
                              2. Accessing contacts
                                1. Retrieving contacts on Android
                                1. Implementing GPS location on Android
                                1. Accessing photos on Android
                                1. Creating Hello World in Xamarin.Forms
                                2. Understanding the architecture behind Xamarin.Forms
                                3. Using XAML in Xamarin.Forms
                                4. Using data binding and MVVM
                                5. Summary
                                1. Following the iOS App Store Review Guidelines
                                  1. General rules
                                  2. Incorrect and incomplete information
                                  3. Content present in the application
                                  4. Apple's 70/30 revenue share
                                  5. General Tips
                                  1. Creating a distribution provisioning profile
                                  2. Adding your app to iTunes Connect
                                  3. Making an iOS binary for the App Store
                                  1. Google Play Developer Program Policies
                                  1. 1. One Ring to Rule Them All
                                    1. Introduction
                                    2. Creating a cross-platform solution
                                      1. Getting ready
                                      2. How to do it.
                                      3. How it works…
                                      4. See also
                                      1. How to do it.
                                      2. How it works…
                                      3. There's more…
                                      1. How to do it.
                                      2. How it works…
                                      3. See also
                                      1. How to do it.
                                        1. For the Android project
                                        2. For the iOS project
                                        1. Introduction
                                        2. Creating a tabbed-page cross-platform application
                                          1. How to do it…
                                          2. How it works…
                                          3. See also
                                          1. How to do it…
                                          2. How it works…
                                          3. See also
                                          1. How to do it…
                                          2. How it works…
                                          3. See also
                                          1. How to do it…
                                          2. How it works…
                                          3. See also
                                          1. Introduction
                                          2. Showing native pages with renderers
                                            1. How to do it…
                                            2. How it works…
                                            3. See also
                                            1. How to do it…
                                            2. How it works…
                                            3. See also
                                            1. How to do it…
                                            2. How it works…
                                            3. See also
                                            1. Introduction
                                            2. Sharing code between different platforms
                                              1. How to do it…
                                              2. How it works…
                                              3. See also
                                              1. How to do it…
                                              2. How it works…
                                              3. See also
                                              1. How to do it…
                                              2. How it works…
                                              3. See also
                                              1. How to do it…
                                              2. How it works…
                                              3. There's more…
                                              4. See also
                                              1. How to do it…
                                              2. How it works…
                                              3. See also
                                              1. How to do it…
                                              2. How it works…
                                              3. There's more…
                                              1. Introduction
                                              2. Creating a shared SQLite data access
                                                1. How to do it…
                                                2. How it works…
                                                3. See also
                                                1. How to do it…
                                                2. How it works…
                                                3. See also
                                                1. How to do it…
                                                2. How it works…
                                                1. How to do it…
                                                2. How it works…
                                                3. There's more…
                                                1. Introduction
                                                2. Creating cross-platform plugins
                                                  1. How to do it.
                                                  2. How it works…
                                                  3. There's more…
                                                  4. See also
                                                  1. How to do it…
                                                  2. How it works…
                                                  3. There's more…
                                                  4. See also
                                                  1. How to do it…
                                                  2. How it works…
                                                  3. See also
                                                  1. How to do it…
                                                  2. How it works…
                                                  3. There's more…
                                                  1. Introduction
                                                  2. Binding data in code
                                                    1. How to do it…
                                                    2. How it works…
                                                    1. How to do it…
                                                    2. How it works…
                                                    1. How to do it…
                                                    2. How it works…
                                                    3. See also
                                                    1. How to do it…
                                                    2. How it works…
                                                    3. See also
                                                    1. Introduction
                                                    2. Displaying a collection and selecting a row
                                                      1. How to do it…
                                                      2. How it works…
                                                      3. See also
                                                      1. How to do it…
                                                      2. How it works…
                                                      3. There's more…
                                                      4. See also
                                                      1. How to do it…
                                                      2. How it works…
                                                      3. There's more…
                                                      4. See also
                                                      1. How to do it…
                                                      2. How it works…
                                                      3. There's more…
                                                      4. See also
                                                      1. Introduction
                                                      2. Adding gesture recognizers in XAML
                                                        1. How to do it…
                                                        2. How it works…
                                                        3. There's more…
                                                        4. See also
                                                        1. How to do it…
                                                        2. How it works…
                                                        1. How to do it…
                                                        2. How it works…
                                                        3. There's more…
                                                        1. Introduction
                                                        2. Creating unit tests
                                                          1. How to do it…
                                                          2. How it works…
                                                          1. How to do it…
                                                          2. How it works…
                                                          3. There's more…
                                                          4. See also
                                                          1. How to do it…
                                                          2. How it works…
                                                          3. See also
                                                          1. How to do it…
                                                          2. How it works…
                                                          3. There's more…
                                                          4. See also
                                                          1. Introduction
                                                          2. Using Xamarin Insights
                                                            1. How to do it…
                                                            2. How it works…
                                                            3. There's more…
                                                            1. How to do it…
                                                            2. How it works…
                                                            1. How to do it…
                                                            2. How it works…
                                                            3. There's more…
                                                            4. See also
                                                            1. How to do it…
                                                            2. How it works…
                                                            3. There's more…
                                                            1. 1. Developing with Xamarin
                                                              1. Cross-platform projects with Xamarin
                                                                1. Xamarin as a platform
                                                                2. Xamarin as a product
                                                                1. Xamarin on Android
                                                                2. Xamarin on iOS
                                                                3. Windows Runtime apps
                                                                1. Choosing the right development OS
                                                                  1. Xamarin Studio setup and configuration
                                                                  2. Visual Studio setup and configuration
                                                                  1. Emulators for Android
                                                                  2. iOS emulation
                                                                  1. Portable class libraries
                                                                  2. Shared projects
                                                                  3. Xamarin.Forms
                                                                  4. NuGet packages
                                                                  5. Components
                                                                  1. Reusability
                                                                  2. Abstraction
                                                                  3. Loose-coupling
                                                                  4. Nativity
                                                                  1. Application Component lifecycle
                                                                    1. Activity lifecycle (Android)
                                                                      1. Active/Running
                                                                      2. Paused
                                                                      3. Backgrounded
                                                                      4. Stopped
                                                                      5. Restarted
                                                                      1. GC on Xamarin projects
                                                                        1. SGen garbage collector
                                                                        2. Boehm garbage collector (iOS only)
                                                                        1. Object reference types
                                                                        2. Automatic Reference Counting (ARC)
                                                                        1. Xamarin Profiler
                                                                          1. Allocations instrument
                                                                          2. Time Profiler
                                                                          1. Disposable objects
                                                                          2. The lapsed listener problem
                                                                          3. Weak references
                                                                          4. Cross-domain objects
                                                                          5. Cyclic references (cycles)
                                                                          1. Multithreading on Xamarin
                                                                            1. Single thread model
                                                                            2. Task-based Asynchronous Pattern
                                                                            3. Concurrency model on iOS
                                                                            1. Continuation
                                                                            2. Cancellation
                                                                            3. Progress
                                                                            4. Task batches
                                                                            1. Async pattern conversions
                                                                            2. Multi-threading with tasks
                                                                            3. Exception handling
                                                                            4. Initialization pattern
                                                                            5. Semaphores
                                                                            1. Background tasks on iOS
                                                                            2. Services (Android only)
                                                                            1. Data in mobile applications
                                                                              1. State
                                                                              2. App data
                                                                              3. Local files
                                                                              4. External data
                                                                              1. Installation directory
                                                                                1. Android
                                                                                2. iOS
                                                                                1. Android
                                                                                2. iOS
                                                                                1. Application preferences
                                                                                2. File picker
                                                                                1. Android and Backup API
                                                                                2. iOS and ubiquitous storage
                                                                                1. Connected apps
                                                                                2. Web services
                                                                                  1. Transport
                                                                                  2. Messaging
                                                                                  3. SOAP/XML services
                                                                                  4. RESTful services
                                                                                  5. OData and OAuth
                                                                                    1. OData
                                                                                    2. OAuth
                                                                                    1. Async conversions
                                                                                    2. Data model abstraction
                                                                                    3. Service cache
                                                                                    1. Permissions
                                                                                    2. NSUrlConnection/NSUrlSession (iOS Only)
                                                                                    3. Background downloads
                                                                                    4. Push notifications
                                                                                    1. Azure Mobile Services
                                                                                    2. Azure offline data
                                                                                    3. Azure authentication
                                                                                    1. Content sharing
                                                                                      1. File pickers and contracts (Windows Store apps)
                                                                                      2. Document Provider extensions (iOS)
                                                                                      3. ContentProvider and ContentResolver (Android)
                                                                                      1. Bluetooth
                                                                                      2. Wi-Fi Direct
                                                                                      3. Near Field Communication
                                                                                      1. Android location and Google Play services
                                                                                      2. Location services on iOS
                                                                                      3. Location data on Windows Runtime
                                                                                      4. Geofencing
                                                                                      1. Managed callable wrappers (Android)
                                                                                      2. Linking versus binding (iOS)
                                                                                      1. Design philosophy
                                                                                        1. User expectations
                                                                                        2. Platform imperatives
                                                                                        3. Hardware dependency
                                                                                          1. Design metrics on Android
                                                                                            1. Design metrics on iOS
                                                                                            2. Design metrics on Windows Runtime
                                                                                            1. The basic layout
                                                                                            2. Navigation
                                                                                              1. Horizontal navigation
                                                                                              2. Vertical navigation
                                                                                              3. Jump navigation
                                                                                              1. Collection views
                                                                                                1. UITableView (iOS)
                                                                                                2. UICollectionView (iOS)
                                                                                                3. ListView (Android)
                                                                                                4. GridView (Android)
                                                                                                5. CardView (Android)
                                                                                                6. ListView and ListBox (Windows Phone)
                                                                                                7. GridView (Windows Phone)
                                                                                                8. Virtualizing panels (Windows Phone)
                                                                                                1. Popover and alerts (iOS)
                                                                                                2. Flyout, popups, and menus (Windows Phone)
                                                                                                3. Dialogs (Android)
                                                                                                1. Indeterminate progress
                                                                                                2. Determinate progress
                                                                                                1. Interactive controls
                                                                                                  1. Text input
                                                                                                  2. Dropdown selection
                                                                                                  3. Option selection
                                                                                                  1. Under the hood
                                                                                                    1. Anatomy of Xamarin.Forms
                                                                                                    2. Project structure
                                                                                                    1. Pages
                                                                                                      1. Tabbed page
                                                                                                      2. The MasterDetail page
                                                                                                      3. NavigationPage
                                                                                                      4. CarouselPage
                                                                                                      5. ContentPage
                                                                                                      1. Styles
                                                                                                      2. Triggers and behaviors
                                                                                                      3. Custom renderers
                                                                                                      1. Messaging infrastructure
                                                                                                      2. Dependency injection
                                                                                                      3. Shared project versus portable project
                                                                                                      4. Platform-specific fine-tuning
                                                                                                      1. Visual assets
                                                                                                        1. Text resources
                                                                                                          1. Xamarin.Android
                                                                                                          2. Xamarin.iOS
                                                                                                          3. Windows Phone
                                                                                                          1. Locale and culture
                                                                                                          2. Windows Phone
                                                                                                          3. Xamarin.iOS
                                                                                                          4. Xamarin.Android
                                                                                                          5. Xamarin.Forms
                                                                                                          1. MVC
                                                                                                            1. iOS app architecture
                                                                                                            1. Windows Runtime
                                                                                                            2. MVVM on Xamarin.iOS and Xamarin.Android
                                                                                                            3. MVVM with Xamarin.Forms
                                                                                                            1. Development pipeline
                                                                                                            2. Troubleshooting and diagnostics
                                                                                                            3. Unit testing
                                                                                                              1. Platform-agnostic unit tests
                                                                                                              2. Platform-specific unit tests
                                                                                                              1. Xamarin.UITests and Xamarin Test Cloud
                                                                                                              2. Xamarin Test Recorder
                                                                                                              3. Coded UI tests (Windows Phone)
                                                                                                              4. Calabash
                                                                                                              1. Source control
                                                                                                                1. TFVC
                                                                                                                2. Git
                                                                                                                3. TFS/Git scenarios
                                                                                                                  1. Git bridge
                                                                                                                  2. NuGet packages
                                                                                                                  1. Visual Studio Team Services
                                                                                                                  2. TeamCity
                                                                                                                  3. Other
                                                                                                                  1. HockeyApp
                                                                                                                  2. Crashlytics
                                                                                                                  3. TestFlight
                                                                                                                  4. Package distribution
                                                                                                                  1. Xamarin Insights
                                                                                                                  2. Application Insights
                                                                                                                  1. Release packages
                                                                                                                    1. Xamarin.Android app package (.apk)
                                                                                                                      1. Disabling debugging
                                                                                                                      2. Linking
                                                                                                                      3. Packing options
                                                                                                                      4. Packaging
                                                                                                                      1. Build options
                                                                                                                      2. Linking
                                                                                                                      3. Provisioning profile
                                                                                                                      1. App store(s)
                                                                                                                      2. Ad-hoc
                                                                                                                      1. Private channel distribution (Android)
                                                                                                                      2. Apple Developer Enterprise Program
                                                                                                                      3. Windows Phone private distribution
                                                                                                                      Show and hide more

                                                                                                                      Product information

                                                                                                                      • Title: Xamarin: Cross-Platform Mobile Application Development
                                                                                                                      • Author(s): Jonathan Peppers, George Taskos, Can Bilgin
                                                                                                                      • Release date: August 2016
                                                                                                                      • Publisher(s): Packt Publishing
                                                                                                                      • ISBN: 9781787120129