Creating an iOS application using Xamarin.Forms and Visual Studio for Mac

Many developers want to try their hand at writing an iOS application. The big drawback has always been learning a new programming language and a new IDE. For some, it is probably not an issue as they want to learn something new. But for many .NET developers, being able to stick to an IDE and programming language they know is immensely empowering. Well, this is exactly what Xamarin.Forms and Visual Studio achieve.

Please note that I am not including Xamarin.Android here as a consideration. I'm purely focusing on writing native iOS and Mac applications.

Xamarin gives .NET developers the ability to use Visual Studio to write applications that can be run cross-platform easily, without having a separate code base for each. You therefore have a single code base for your application that will run on Windows, iOS/macOS, and Android. If you want to get into developing native iOS/macOS applications, you basically have (to my mind anyway) four viable options. They are as follows:

  • Buy yourself a Mac and teach yourself Xcode, Swift, and/or Objective-C. 
  • Buy yourself a Mac and install Parallels, where you can install Windows, Visual Studio, and other Windows-based software (Mac is not exclusively used for development). You can see a video on the Developer Community YouTube channel I created a few years back (https://www.youtube.com/developercommunity). In that video, I show you how to install Visual Studio 2013 on a Mac using Parallels.
  • Buy yourself a Mac and download Visual Studio for Mac (currently still in preview at the time of writing) and install that on your Mac (Mac is exclusively used for developing Android and iOS/macOS applications).
  • Buy yourself a Mac and use that to compile iOS/macOS applications developed on your Windows PC running Visual Studio. Do this if you need to create applications that can still target Windows-based platforms in addition to Android and iOS/macOS.
If you are going to be using Visual Studio for Mac and Xamarin.Forms, then you will not be able to create Xamarin.Forms projects for Windows and Windows phone because these cannot be build on macOS. Also note that I didn't consider MacinCloud here because somewhere along the development process, I believe that it is really beneficial to own a physical Apple Mac device.

From the points listed earlier, it is clear that you are going to need a Mac. While it is entirely possible to have Visual Studio installed on your Windows PC and connect to the Xamarin Mac agent when the machines are on the same local network, it does become a bit of an inconvenience when you need to try and remotely access the Mac (from your work office, for example). While theoretically this should be possible, you need to do some legwork to make this all work. For one, you will probably need to add some sort of port forwarding on your router to allow remote connections to your Mac. You will also need to assign your Mac a static IP address (or even buy a static IP address for your router) so that if a restart happens due to a power failure when you are working remotely, you will still be able to access your Mac for your Visual Studio builds.

Installing Parallels on your Mac is great, and will really come in handy when you have other Windows-based software that you want to use on your Mac. If you (like me) use your Mac exclusively for development purposes, then Parallels might not be a viable solution. This leaves Visual Studio for Mac and is a great option if you only plan to develop iOS/macOS and Android applications.

To download Visual Studio for Mac, head on over to https://developer.xamarin.com/visual-studio-mac/ and click on the download link. The installation process is somewhat similar to the installation process in the first recipe of this chapter. The difference here is that the actual Visual Studio application will be installed on the Mac and not on a Windows PC on the same network.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.209.201