Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
lawrence_shaun_introducing_net_maui_build_and_deploy_crosspl.pdf
Скачиваний:
46
Добавлен:
26.06.2023
Размер:
5.15 Mб
Скачать

CHAPTER 2

Building Our First application

In this chapter, you will learn how to set up your development environment across all of the required platforms. You will then use that environment to create, build, and run your very first .NET MAUI

application. Finally, you will take a look at the application you will build as you progress through this book.

Setting Up Your Environment

Before you get into creating and building the application, you must make sure you have an environment set up.

macOS

There are several tools that you must install on macOS to allow support for building Mac Catalyst applications and to provide the ability to build iOS applications from a Windows environment.

© Shaun Lawrence 2023

19

S. Lawrence, Introducing .NET MAUI, https://doi.org/10.1007/978-1-4842-9234-1_2

 

Chapter 2 Building Our First application

This is required if you wish to develop on macOS or deploy to a Mac or iOS device (even from a Windows machine). If you are happy with only deploying to Windows or Android from a Windows machine, then you can skip this part or just read it for reference.

Visual Studio for Mac

As mentioned in the previous chapter, you will be primarily focusing on using Visual Studio on Windows. You will have a requirement to use Visual Studio for Mac much later, but you will set it up now. Also note that while the book does focus on using Visual Studio on Windows, quite a lot of the concepts should still translate well enough to Visual Studio for Mac if that is your preferred environment.

Download and install Visual Studio 2022 for Mac. This can be accessed from https://visualstudio.microsoft.com/vs/mac/.

\1.\ Open the downloaded

VisualStudioForMacInstaller.dmg file.

\2.\ Double-click the Install Visual Studio for Mac option. Figure 2-1 shows the Visual Studio for Mac installer.

20

Chapter 2 Building Our First application

Figure 2-1.  Visual Studio for Mac installer

\3.\ You will likely be shown a security dialog making sure that you wish to run this installer. Double check the details and then proceed if all looks fine.

\4.\ Accept the terms and conditions by clicking

Continue.

\5.\ In the next window, select .NET, Android, iOS, and macOS (Cocoa) and then click Install. Figure 2-2 shows the installer with the required options for

.NET MAUI checked.

21

Chapter 2 Building Our First application

Figure 2-2.  Visual Studio for Mac installation options

Please refer to the Microsoft documentation page at https://learn. microsoft.com/dotnet/maui/get-started/installation?tabs=vsmac if any of the installation options have changed.

Xcode

Xcode is Apple’s IDE for building applications for iOS and macOS. You don’t need to use Xcode directly, but Visual Studio needs it in order to compile your iOS and macOS applications.

Thankfully this install is straightforward despite it being a rather large download.

\1.\ Open the App Store application.

\2.\ Enter Xcode into the Search box and press return.

22

Chapter 2 Building Our First application

\ 3.\ Click Get. Figure 2-3 shows Xcode available on the Apple App Store.

Figure 2-3.  Xcode on the App Store

\ 4.\ Once downloaded, open Xcode and wait for it to install the command line tools. Note that this is usually required to be performed after each major update to Xcode, too.

I suggest using caution when applying updates to the whole suite of applications that you are installing today. Typically, when a new, big release of .NET MAUI comes out, it likely requires an update of Xcode. I personally like to keep these expected versions in sync so I recommend checking for the updates within Visual Studio first and

verifying that it expects a new version of Xcode before proceeding to update that.

23