This guide describes how to use Pair to Mac to connect Visual Studio 2019to a Mac build host. The same instructions apply to Visual Studio 2017.
Overview
Xamarin.Mac exposes the complete macOS SDK for.NET developers to build native Mac applications using C#.
Building native iOS applications requires access to Apple's build tools,which only run on a Mac. Because of this, Visual Studio 2019 must connect toa network-accessible Mac to build Xamarin.iOS applications.
Visual Studio 2019's Pair to Mac feature discovers, connects to,authenticates with, and remembers Mac build hosts so that Windows-basediOS developers can work productively.
Pair to Mac enables the following development workflow:
Before following the instructions in this guide, complete the following steps:
If you would prefer not to install Visual Studio for Mac, Visual Studio 2019can automatically configure the Mac build host with Xamarin.iOS and Mono.You must still install and run Xcode.For more information, see Automatic Mac provisioning.
Enable remote login on the Mac
To set up the Mac build host, first enable remote login:
Connect to the Mac from Visual Studio 2019
Now that remote login is enabled, connect Visual Studio 2019 to the Mac.
If you have successfully paired to a Mac build host, you are ready to buildXamarin.iOS apps in Visual Studio 2019. Take a look at theIntroduction to Xamarin.iOS for Visual Studioguide.
If you have not been able to pair a Mac, try manually adding aMac or take a look at the troubleshootingguide.
Manually add a Mac
If you do not see a particular Mac listed in the Pair to Mac dialog,add it manually:
Automatic Mac provisioning
Starting with Visual Studio 2019 version 15.6,Pair to Mac automatically provisions a Mac with software necessary forbuilding Xamarin.iOS applications: Mono, Xamarin.iOS (the softwareframework, not the Visual Studio for Mac IDE), and various Xcode-relatedtools (but not Xcode itself).
Important
Pair to Mac performs necessary software installations/updates when VisualStudio 2019 is connecting to theMac.
Mono
Pair to Mac will check to make sure that Mono is installed. If it is notinstalled, Pair to Mac will download and install the latest stable versionof Mono on the Mac.
Progress is indicated by various prompts, as shown by the followingscreenshots (click to zoom):
Visual Studio For Mac Download
Xamarin.iOS
Pair to Mac upgrades Xamarin.iOS on the Mac to match the versioninstalled on the Windows machine.
Important
Pair to Mac will not downgrade Xamarin.iOS on the Mac from alpha/betato stable. If you have Visual Studio for Mac installed, set yourrelease channel asfollows:
Progress is indicated by various prompts, as shown by the followingscreenshots (click to zoom):
Xamarin App Development Visual Studio For Mac FreeXcode tools and license
Pair to Mac will also check to determine whether Xcode has been installedand its license accepted. While Pair to Mac does not install Xcode, itdoes prompt for license acceptance, as shown in the following screenshots(click to zoom):
Additionally, Pair to Mac will install or update various packagesdistributed with Xcode. For example:
Xamarin Studio Mac
The installation of these packages happens quickly and without a prompt.
Note
These tools are distinct from the Xcode Command Line Tools, whichas of macOS 10.9 areinstalled with Xcode.
Troubleshooting automatic Mac provisioning
If you encounter any trouble using automatic Mac provisioning, take a lookat the Visual Studio 2019 IDE logs, stored in%LOCALAPPDATA%XamarinLogs16.0. These logs may contain error messagesto help you better diagnose the failure or get support.
Build iOS apps from the Windows command-line
Pair to Mac supports building Xamarin.iOS applications from the commandline. For example:
The parameters passed to
msbuild in the above example are:
Note
Visual Studio 2019 stores
msbuild in the following directory:C:Program Files (x86)Microsoft Visual Studio2019<Version>MSBuildCurrentBin
The first time Pair to Mac logs in to a particular Mac build host fromeither Visual Studio 2019 or the command-line, it sets up SSH keys. With thesekeys, future logins will not require a username or password. Newlycreated keys are stored in %LOCALAPPDATA%XamarinMonoTouch.
If the
ServerPassword parameter is omitted from a command-line buildinvocation, Pair to Mac attempts to log in to the Mac build hostusing the saved SSH keys.
Summary
This article described how to use Pair to Mac to connect Visual Studio 2019 to aMac build host, enabling Visual Studio 2019 developers to build native iOSapplications with Xamarin.iOS.
Next steps
I was experimenting with cross-platform development for some time but it's only yesterday I tried to compile my code for iOS. I thought I could do development including UI design in either Visual Studio or Xamarin Studio and only deploy the app on a Mac hardware to do a check on device. The biggest surprise was that Xamarin Studio didn't support iOS projects on Windows. I was expecting more limitations on a Visual Studio side, not on the IDE owned by Xamarin. This left me only Visual Studio to do iOS development. But can I do the full circle, including UI design? I am not planning any sophisticated UIs, so far it's been mostly research of opportunities, and I am striving to put as much as possible in portable class libraries. To perform a test run of the app I opened a 'pay-as-you-go' account at MacInCloud and managed to run my app in a simulator, I also ran unit tests there. It works but performance is sluggish and you can't really develop on these VMs, they are just for tests. This brings me to the question of an optimal setup: I plan to buy a new machine soon and originally I was thinking about a powerful Windows 8 laptop. But since I won't be able to run Xamarin Studio for iOS projects on such machine, and Mac-in-cloud seems to be suitable only for short test sessions, looks like I will need to invest in some Mac hardware. Then the question is whether to have a Mac Mini companion to a Windows machine or to get for about the same price a decent MacBook.
So I appreciate an advice on a decent setup for cross-platform app development. What works best for you? Should I always have a decent Mac notebook if I include iOS in the set of supported platforms?
Thanks in advance
Comments are closed.
|
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |