Reader small image

You're reading from  .NET MAUI Cross-Platform Application Development - Second Edition

Product typeBook
Published inMar 2024
Reading LevelBeginner
PublisherPackt
ISBN-139781835080597
Edition2nd Edition
Languages
Right arrow
Author (1)
Roger Ye
Roger Ye
author image
Roger Ye

Roger Ye is an embedded system programmer who has great interest in virtualization, Android, and cross-platform technologies. His professional experience includes working with major companies like Motorola, Emerson, Intel, and EPAM, where he held the position of Engineering Manager. At Motorola and Emerson, he worked on embedded system projects for mobile devices and telecommunication infrastructures. He is now an engineering manager at EPAM, working with a team to deliver digital solutions for diverse clients.
Read more about Roger Ye

Right arrow

Getting Started with .NET MAUI

Since the release of .NET 5, Microsoft has been trying to unify different .NET implementations into one .NET release. .NET Multi-platform App UI (or .NET MAUI) is the effort to provide a unified cross-platform UI framework. We will learn how to use .NET MAUI to develop cross-platform applications in this book.

The following is what we will cover in this chapter:

  • Overview of cross-platform technologies
  • Comparison of cross-platform technologies (.NET, Java, and JavaScript)
  • .NET landscape and the history of Xamarin
  • .NET MAUI features
  • .NET MAUI Blazor apps
  • What’s new in .NET 8 for .NET MAUI?
  • Development environment setup

If you’re new to .NET development, this chapter will help you to understand the .NET landscape. For Xamarin developers, many topics in this book may sound familiar; this chapter will give you an overview of what we will discuss in this book.

Overview of cross-platform and full stack technologies

.NET Multi-platform App UI, or .NET MAUI, is a cross-platform development framework from Microsoft for building apps that targets both mobile and desktop form factors on Android, iOS, macOS, Windows, and Tizen. It is one of a number of cross-platform frameworks available on the market.

Before discussing cross-platform technologies, let’s review the scope of application development first. This review will help us to understand the various cross-platform frameworks better.

Generally, software development can be divided into two categories – systems programming and application programming. Application programming aims to produce software that provides services to the user directly, whereas systems programming aims to produce software and software platforms that provide services to other software. In the .NET domain, the development of the .NET platform itself belongs to systems programming, whereas application...

Exploring the .NET landscape

Before we dive into the details of .NET MAUI, let’s have an overview of the .NET landscape. This is a section for those who are new to .NET. If you are a .NET developer, you can skip this section.

Since Microsoft introduced the .NET platform, it has evolved from a proprietary software framework for Windows to a cross-platform and open-source platform.

There are many ways to look at the .NET technology stack. Basically, it contains the following components:

  • Common infrastructure (compiler and tools suite)
  • Base Class Library (BCL)
  • Runtime (WinRT or Mono)

.NET Framework

The history of .NET started with .NET Framework. It is a proprietary software framework developed by Microsoft that runs primarily on Microsoft Windows. .NET Framework started as a future-oriented application framework to standardize the software stack in the Windows ecosystem. It is built around the Common Language Infrastructure (CLI) and...

Using Xamarin for cross-platform development

As we mentioned in the previous section, Xamarin was part of the Mono project and was an effort to support .NET on Android, iOS, and macOS. Xamarin exports the underlying operating system features to the .NET runtime. Xamarin.Forms is the cross-platform UI framework of Xamarin. .NET MAUI is an evolution of Xamarin.Forms. Before we discuss .NET MAUI and Xamarin.Forms, let us review the following diagram of Xamarin implementations on various platforms.

Figure 1.1: Xamarin implementations

Figure 1.1 shows the overall architecture of Xamarin. Xamarin allows developers to create native UIs on each platform and write business logic in C# that can be shared across platforms.

The transition from Xamarin to .NET MAUI, or more specifically from Xamarin.Forms to .NET MAUI, is not a revolution. .NET MAUI essentially represents a new version of Xamarin.Forms rather than other components of Xamarin. Xamarin.Android has now become...

Moving to .NET MAUI

With the .NET unification, Xamarin has become a part of the .NET platform, and Xamarin.Forms is integrating with .NET in the form of .NET MAUI.

.NET MAUI is a first-class .NET citizen with the namespace Microsoft.Maui.

Making the move to .NET MAUI is also an opportunity for Microsoft to redesign and rebuild Xamarin.Forms from the ground up and tackle some of the issues that have been lingering at a lower level. Compared to Xamarin.Forms, .NET MAUI uses a single project structure, supports hot reloads better and supports the MVU and Blazor development patterns.

It’s important to note that MVU is not currently available as a stable method for building apps with .NET MAUI; it has only been announced.

Figure 1.2 shows an architecture diagram of .NET MAUI; you can find it in the Microsoft documentation. From Figure 1.2, we can see that there is a common BCL for all supported operating systems. Under the BCL, there are two runtimes...

What’s new in .NET 8 for .NET MAUI?

.NET 8 introduced many new changes, and here we will review the aspects related to .NET MAUI.

Native AOT support for iOS-like platforms

.NET 8 introduces native AOT support for iOS-like platforms, allowing the building and running of .NET iOS and .NET MAUI applications on various platforms. Preliminary testing shows a 40% disk size decrease for .NET iOS apps and a 25% increase for .NET MAUI iOS apps using native AOT. However, as this is only the first step in support, performance conclusions should not be drawn yet. Native AOT support is an opt-in feature for app deployment, while Mono remains the default runtime for development and deployment.

.NET MAUI extension of Visual Studio Code

Although still in its preview stage, Visual Studio Code now offers a .NET MAUI extension, making it available for use in .NET MAUI development. The .NET MAUI extension is a new Visual Studio Code extension that lets you develop and debug your...

Development environment setup

In this section, we will introduce the development environment setup in Visual Studio and Visual Studio Code.

Using Visual Studio

Both Windows and macOS can be used for.NET MAUI development, but you won’t be able to build all the targets with only one of them. You will need both Windows and Mac computers to build all the targets. In this book, the Windows environment is used to build and test Android and Windows targets, while iOS and macOS targets are built on a Mac computer.

.NET MAUI apps can target the following platforms:

  • Android 5.0 (API 21) or higher
  • iOS 11 or higher
  • macOS 10.15 or higher, using Mac Catalyst
  • Windows 11 and Windows 10 version 1809 or higher, using Windows UI Library (WinUI) 3

.NET MAUI Blazor apps use the platform-specific WebView control, so they have the following additional requirements:

  • Android 7.0 (API 24) or higher
  • iOS 14 or higher
  • macOS 11 or...

Summary

In this chapter, we explored topics related to .NET MAUI and Xamarin, discussing various cross-platform technologies in comparison to .NET MAUI. This analysis provided insight into the advantages and disadvantages of different frameworks. Additionally, we compared the JavaScript and C# ecosystems, as most cross-platform frameworks utilize these languages. By introducing the .NET landscape and the available cross-platform frameworks, you now have a comprehensive understanding of the essentials before delving into the world of .NET MAUI.

In the next chapter, we will explore how to build a .NET MAUI application from scratch.

Further reading

Learn more on Discord

Join our community’s Discord space for discussions with the author and other readers:

https://packt.link/cross-platform-app

lock icon
The rest of the chapter is locked
You have been reading a chapter from
.NET MAUI Cross-Platform Application Development - Second Edition
Published in: Mar 2024Publisher: PacktISBN-13: 9781835080597
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Roger Ye

Roger Ye is an embedded system programmer who has great interest in virtualization, Android, and cross-platform technologies. His professional experience includes working with major companies like Motorola, Emerson, Intel, and EPAM, where he held the position of Engineering Manager. At Motorola and Emerson, he worked on embedded system projects for mobile devices and telecommunication infrastructures. He is now an engineering manager at EPAM, working with a team to deliver digital solutions for diverse clients.
Read more about Roger Ye