Section 1: Understanding .NET
The fundamental requirement for implementing cross-platform applications with Xamarin is to understand the .NET ecosystem and the supporting Microsoft stack. This part of the book specifically walks you through the evolution of .NET and how it can efficiently be utilized for mobile projects.
This section comprises the following chapters:
- Chapter 1, Getting Started with .NET 5.0
- Chapter 2, Defining Xamarin, Mono, and .NET Standard
- Chapter 3, Developing with Universal Windows Platform
Chapter 1: Getting Started with .NET 5.0
.NET Core (previously known as .NET vNext) is the general umbrella term used for Microsoft's cross-platform toolset that aims to solve the shortcomings of centralized/machine-wide frameworks (classic .NET Framework) by creating a portable, platform-agnostic, modular runtime and framework. This decentralized development platform, which is replacing the classic .NET Framework starting with v5.0, allows developers to create applications for multiple platforms using the common .NET base class libraries (implementation of the .NET standard), as well as various runtimes and application models, depending on the target platforms.
This chapter will give you a brief introduction to the new .NET Framework while explaining different tiers of the .NET Core infrastructure. The combination of .NET Core, .NET Standard, and Xamarin is the key to cross-platform projects and opens many doors that were previously only available to Windows developers. The ability to create web applications that can run on Linux machines and containers, and the implementation of mobile applications that target iOS, Android, Universal Windows Platform (UWP), and Tizen, are just a couple of examples designed to emphasize the capabilities of this cross-platform approach.
In this chapter, we will analyze cross-platform development tools and frameworks for mobile applications and take an initial look at .NET Core development.
The following sections will guide you through getting started with .NET 5.0:
- Exploring cross-platform development
- Understanding .NET Core
- Developing with .NET 5.0
Technical Requirements
You can find the code used in this chapter through the following GitHub link: https://github.com/PacktPublishing/Mobile-Development-with-.NET-Second-Edition/tree/master/chapter01/src.
Exploring cross-platform development
The term cross-platform application development refers to the process of creating a software application that can run on multiple operating systems. In this book, we will not try to answer the question of why, but how to develop cross-platform applications – more specifically, we will try to create a cross-platform application using the toolset provided by Microsoft and .NET Core.
Before we start talking about .NET Core, let's take a look at the process of developing an application for multiple platforms. Faced with the cross-platform requirement, the product team can choose multiple paths that will lead the developers through different application life cycles.
Throughout this book, we will have hypothetical user stories defined for various scenarios. We will start with an overall user story that underlines the importance of .NET Core:
"I, as a product owner, would like to have my consumer app running on iOS and Android mobile platforms, as well as Windows, Linux, and macOS desktop runtimes, so that I can increase my reach and user base."
In order to meet these demands, we can choose to implement the application in several different ways:
- Fully native applications
- Hybrid applications
- Cross-platform
Let's take a look at each of these methods.
Developing fully native applications
Following this path would create probably the most performant application, with increased accessibility to platform APIs for developers. However, the development team for this type of development would require a wider range of skills so that the same application can be created on multiple platforms. Development on multiple platforms would also increase the developer hours that need to be invested in the application.
Considering the scenario presented in the previous section, we would potentially need to develop the client application in Cocoa and CocoaTouch (macOS and iOS), Java (Android), .NET (Windows), and C++ (Linux), and finally build a web service infrastructure using another development platform of our choice. In other words, this approach is, in fact, implementing a multi-platform application rather than a cross-platform one.
Hybrid applications
Native hosted web applications (also known as hybrid applications) are another popular choice for (especially mobile) developers. In this architecture, a responsive web application would be hosted on a thin native harness on the target platform. The native web container would also be responsible for providing access to the web runtime on native platform APIs. These hybrid applications wouldn't even need to be packaged as application packages, but as Progressive Web Apps (PWAs) so that users can access them directly from their web browsers. While the developmen...