Introduction to Cross-Platform Mobile Development (XAM110)

One of the advantages to using Xamarin over the traditional platform-specific approach is the level of code-sharing you can achieve across iOS, Android, and Windows. In this class, we will explore ways to structure your shared code using Portable Class Libraries, .NET Standard libraries, and Shared Asset Projects. We will look at the pros and cons of each approach and see how to access platform-specific features in each model.

Upon completion you will be able to:

Course exercise download

Exercise materials are available from GitHub. The code can be cloned through a desktop Git client or downloaded directly as a ZIP file.

If you are using Windows, try to select a location with a shorter path length to make sure you don't exceed the 260 character limit.

Lecture

Here are the lecture slides.

Exercises

  1. Exercise 1: Share code using a Shared Project

    The goal of this exercise is to load data from a JSON file and display it in an existing Xamarin application. The code to manage loading the file will be shared between the platform-specific projects using a Shared Project.

  2. Exercise 2: Share code using Portable Class Libraries

    We will work on the same project we did in the previous exercise, but this time we will use a Portable Class Library to share our JSON data loading between the iOS, Android and Windows projects. We will be starting almost where you left off in the last exercise, without the Shared Project implementation, but the code in the platform projects has already been filled out.

  3. Exercise 3: Share code using a .NET Standard library

    To explore .NET Standard class libraries, we will implement some shared code within a few .NET Standard target versions to see how it affects the available APIs.

  4. Exercise 4: Upgrade a Portable Class Library to .NET Standard

    We will work on the same project we did in the previous exercise. To explore the interoperability of Portable Class Libraries and .NET Standard class libraries, we will migrate our code from the MyTunes PCL library to our library targeting .NET Standard.

Additional resources

Popular components

Here are some popular open-source projects from Xamarin, you can install these into your applications using NuGet.

Cross platform Xamarin and Windows plugins for PCLs Xamarin.Mobile cross-platform abstraction for Contacts, Geolocation and the camera Cross-Platform authentication API (OAuth)

High Level Concepts (Review)

Building Cross Platform Applications Sharing Code Options Cross-Platform Data Access Cross-Platform Web Services