From the course: Xamarin Essential Training: Create Your First App

Set up a Mac for development

- [Instructor] You're ready to start developing your Xamarin application. You may start on a Mac. And you might think you can just jump right in and install Visual Studio and get started. But before you do that, you actually need some specific tools from Apple to build your iOS and Mac applications. Xcode is the Apple provided IDE for developing applications for iOS and Mac. You can go and find Xcode, if you don't already have it installed, by just going in the App Store here, searching for Xcode. You'll find some related things, tools and cleaners and code and books. But here you've got the Xcode under developer tools that you can go ahead and install. And in your case, if you haven't installed it before, you have a 'GET' button like you see on these other applications. In my case, I have the little cloud download that tells me I could download a different version of it. And if I go to updates, I'll see that that's actually got Xcode 14, it's telling me I could update too that came out recently. Now I'm not going to update right now, because I happen to know that in this particular window while I'm recording the Xamarin tools aren't yet updated to support that version of Xcode cuz it just came out days ago. So I'm going to leave that Xcode version alone. I've gone to the Apple developer portal, and installed an older version and we can go run it here. You can see I've got version 13.4.1 here, whereas version 14 was what was available in the store. When you first run Xcode, you'll probably get a dialogue that tells you it needs to install additional components. That's why I'm running it to show you that you are going to need to not just install it, but run it in order to get those extra components installed. In my case, I've run it once before and it's done that work. If you update Xcode or you have automatic updates turned on, you'll want to run it again, cuz it may then update those components. And now we can install Visual Studio. I go into my downloads folder here. You can see I've downloaded the installer for Visual Studio for Mac. It's a disc image, so if I double click it, disc image opens and I can run the installer here. It's going to warn me it's downloaded from the internet. I'm going to say I'm going to go ahead and open it. It's going to do some checking here, so I need to ... provide some credentials to allow it to do some installs. So it's checking for all the different components that it needs that it might install to see if they're already there. So you can see here, I've already done the installation, but I wanted to run the installer so you can see the different components that you would select in a new installation, and also so you can see that it is possible to go back and change those options. You can see we've got .NET installed. It's part of the core that's got .NET 6, some patches on it, we've got .NET MAUI in there. And some other items we could add. We could add our Mac OS if we want to build Mac applications. And then under the Legacy, you'll see I've got Android and iOS selected here. So these are going to be the SDKs that I use to build those native Android and iOS application user interfaces with the shared C# code library. So those things are all installed already. I'm ready to go, but if I chose to come back and add additional workloads, I could come into the installer and add those things here. Go ahead and close out of that, and we can inject our disc image to get us back here or we can then run Visual Studio. So we'll create a new project. Let's just create a quick iOS application. We'll do a single view application. Click 'Continue' and we'll just call this our setup test. We're going to target iOS 15.4 here and I want to support both iPhone and iPad. I could turn on version control. It's going to create me a solution and a project here. Now because I have Xcode installed, one of the things it installed was an iOS simulator and that means that I can come in here and choose different versions of iPhones or iPads along with different versions of the operating system. Now notice that not all of them are here in 15.5 and 15.4. Go to some of these others, you'll see that's consistent. Those are things I can control through my Xcode preferences and configuration. I can install different versions of the simulators and these versions of iOS. So now I should be able to run this if I've got everything all set up correctly. Should have my Xamarin iOS pieces installed along with this Visual Studio installed. I've got the underlying components from Apple that I need in terms of Xcode and any additional components it installs. All runs a simulator here for me, simulating my iPhone, runs my application, which is extremely boring, cuz it's just this white background here. Now I can go up to the device menu in the simulator and I can hit the home button, or I can use the keyboard combination and that takes me back out here to the home. And I can long hold this just like I would on an actual device. I can do things like delete, and I also have the ability to click and swipe just like I would on a device. So I'm all set up now on my Mac to do that iOS development with the underlying components of Visual Studio and Xcode.

Contents