Xamarin Dev Environment: connecting Visual Studio from a Windows VM to iOS & Android emulators running on Mac

Pavel Sulimau
Sep 21 · 5 min read

The choice of tools to be used in the software development process can literally make or break a project, so it’s vitally important to be aware of the options and choose the one that suits you most.

To be able to build and debug a Xamain iOS project you have to be on a macOS machine or at least have a connection to macOS. And this is the place where you have options…

The main question here is whether you’re satisfied with what Visual Studio for Mac offers to you. If you feel comfortable with it, then just stay on macOS and skip reading this article. But if you miss the Visual Studio with/without Resharper then you may want to choose one of the following options depending on the physical machine(s) you have in your possession.

1. A Windows machine with a connection to a macOS machine.

If you have both Windows and macOS machines which you can use simultaneously, then you can work on the Windows machine connected to your macOS machine for building Xamarin iOS projects.

If you don’t have an Apple computer at your possession and you don’t want to buy it in the near future, you may want to rent one using a cloud service (i.e. https://www.macincloud.com/).

2. A macOS machine with Windows running on it inside a virtual machine.

If you have a powerful Apple computer like Macbook Pro 15, then you should have enough resources to host a Virtual Machine like Parallels / VMWare Fusion / Virtual Box with Windows OS plus Visual Studio inside.

Let’s assume that you have already set up a Windows VM with Visual Studio on your Mac.

The interesting part here is how you should run and connect to iOS and Android emulators.

With iOS emulators everything is straightforward to configure.

As Pair to Mac for Xamarin.iOS development documentation says the setup can be accomplished with the following steps:

  1. Enable remote login on your Mac.

2. Connect to the Mac from Visual Studio 2019.

  • Select Tools > iOS > Pair to Mac.
  • Use your Mac name, username, and password to establish the connection.

The iOS part is done, you can now access the iOS emulator and debug your apps.

Let’s configure the connection to an Android emulator.

I wouldn’t recommend installing an Android emulator inside the virtual Windows OS as in this case the Android emulator will be the virtual machine inside another virtual machine which will give you nothing but problems with its installation and poor performance. A better approach is to run an Android emulator inside the host macOS system and connect to it from the virtual Windows OS through SSH. The same approach was used implicitly by Visual Studio 2019 when it was paring with the Mac in the iOS emulator case. There is a couple of ways how to configure this, but the most convenient for me is located here and labeled “Alternate method using SSH”.

Here are the steps that you’ll need to go through:

  1. Install Android Studio in macOS and create an Android emulator using Android Virtual Device Manager.

The emulator CANNOT have Google Play Store enabled. It can be x86 or x64, it can have Google APIs, but not Google Play selected. You will get “unauthorized” when running adb devices from the windows machine.

2. Start the Android emulator, open terminal and with the following command identify the emulator’s ports:

lsof -iTCP -sTCP:LISTEN -P | grep ‘emulator\|qemu’

3. Install an SSH client on Windows. One option is to install Git for Windows. The ssh command will then be available in the Git Bash command prompt.

4. Run ssh on Windows to set up two-way port forwarding between a local port on Windows (localhost:15555 in this example) and the odd-numbered emulator port on the Mac's loopback interface ( in this example):

ssh -L localhost:15555: mac-username@name-of-the-mac

5. In Visual Studio open Android Adb command prompt through Tools > Android > Android Adb Command Prompt and use this command to connect to the emulator:

adb connect localhost:15555

After running this command you should be able to see the emulator in the Visual Studio’s dropdown.

Happy debugging!

Sources and links with answers for possible errors:

Pavel Sulimau

Written by

Software Engineer interested in .NET Core, Xamarin, and Flutter.