Xamarin Visual Studio For Mac

I’ve been struggling with carrying a Mac and PC for Xamarin development for a couple years now. Wouldn’t it be nice to just run OS X in a VM so I could use my Surface Book and not mess with the Apple ecosystem more than necessary? Well, I finally got it working, thanks in large part to the work that’s been done by many people, links of which I’ll credit in this article. Thanks, all!

  1. Visual Studio For Mac Tutorial
  2. Xamarin Build Ios From Windows
  3. Xamarin Visual Studio For Mac

Requirements

If you plan to do iOS development, you will need Visual Studio on your PC and a Mac host computer with the Xamarin tools installed. You will do your development on the Windows computer in Visual Studio and the Mac will build and package the iOS application using Apple’s tools. I tried creating a Xamarin.Mac project that references a.NET Standard project (shared) and the.resx file informatiom in the.NET Standard project was then used in the Xamarin.Mac project without any problems.

  • macOS X Sierra Installer, or a machine with Sierra installed – extraction details below
  • Intel powered machine, preferably i5 or higher
  • 16GB or larger thumb drive, preferably USB 3
  • VirtualBox 5.x
  • Visual Studio 2015 or higher
  • If on a laptop, you’re plugged in

Create the OS X Installer USB Drive

First things first – you’ll need a Mac running Sierra and at least a 16 GB USB thumb drive. We’ll be using Unibeast, Multibeast, and the Clover bootloader. I imagine you own both Mac OS and the drive. I’d go the USB 3.0 or higher route so things run a bit faster. We’ll be extracting a Sierra installer in a moment. If you’re all set with the above, follow the instructions at the awesome Tony Mac x86 website. Special thanks to the Hackintosh website. When asked whether to use UEFI or Legacy boot mode, choose Legacy. Here is a marked-up PDF of the article in case the link doesn’t work.

In a nutshell, here’s what you’ll be doing in this step:

  1. Insert the thumb drive into the Mac. Launch Disk Utility and format the USB drive with the name USB and the format of GUID Partition Map.
  2. Download the macOS Sierra installer via the App Store. The installer will be saved in your Applications folder. Make a copy of it somewhere, just in case it gets deleted and you need it again. Don’t move the installer.
  3. Download and Run Unibeast and follow the prompts. Use Legacy boot mode. You’ll need a [free] account on the Tony Mac x86 site to download, fyi.
  4. Let Unibeast create the thumb drive. This will take about 10 minutes on a USB 3 drive.
  5. Download and Copy Multibeast to the newly created Unibeast drive.
  6. You’re now ready to start configuring VirtualBox.

Create the VirtualBox USB Drive Shim

You have a USB thumb drive, but VirtualBox doesn’t make it easy to boot from such a device. You’ll need to create a fake virtual disk that points to the USB drive. This tutorial walks you through it. Here’s a PDF if that link doesn’t work.

In a nutshell, here’s what you’ll be doing in this step:

  1. Open Disk Management and get the Disk Number of the thumb drive, as shown below
  2. Open command prompt as an administrator
  3. Navigate to %programfiles%oraclevirtualbox
  4. Run the command

    to create the virtual drive pointer

  5. You’re now ready to create the VirtualBox virtual machine.

Create the VM

Windows won’t allow VirtualBox to use the USB shim you just created unless you launch with administrator privileges. Right-click VirtualBox and select Run as Administrator. VirtualBox should open. Then, follow the instructions on this page.Ignore the download portion – you already have an install thumb drive, and you just want the VM configuration steps. If that link doesn’t work, here’s a PDF.

In a nutshell, here’s what you’ll be doing in this step:

  1. Create a new Virtual Machine, name it Sierra – although that’s not a requirement – and choose OS X 64-bit as the guest OS. VirtualBox’s settings aren’t fully correct, but we’ll get there.
  2. Choose 4 GB of RAM. I didn’t test with any other memory configs. So, YMMV if you go another route.
  3. When asked which drive to use, choose an existing drive, and select the USB shim you created in the previous section. The example above saved the file as usb.vmdk at the root of C:
  4. You should now have a VM, like every other time you’ve used VirtualBox 🙂
  5. Add another Virtual Disk to stand in as your Mac’s hard drive. I suggest VDI format, dynamically sized, and 60 GB in size. Ignore that my screen shot shoes 40 GB <grin> In future steps you’ll need to install XCode and Xamarin Studio. Don’t skimp on size here or you’ll be reinstalling later. Much sad.

Note: XCode uses a lot of space when it updates. Don’t skimp on virtual disk size. If that’s a big deal, save the VM’s drive to a location that will have enough space.

Once you’ve added the hard drive, you’ll need to finish configuring the VM. You already have an installer on the thumb drive.

Aside from the defaults, confirm the settings you have match settings below. I’ve also included some screen shots a little further down.

  1. After performing the steps above, you’ll be using the following settings in your VM:
    • System, Motherboard, Base Memory: 4096 MB
    • System, Motherboard, Boot Order: Only Optical and Hard Disk checked
    • System, Motherboard, Pointing Device: USB Tablet
    • System, Motherboard, Chipset: ICH9
    • System, Motherboard, Extended Features: Enable I/O APIC, Enable EFI, Hardware Clock in UTC Time, all checked
    • System, Processor, Processors: 2 CPUs
    • System, Processor, Execution Cap: 100%
    • System, Processor, Enable PAE/NX: Checked
    • Display, Screen, Video Memory: 128 MB
    • Display, Screen, Monitor Count: 1
    • Display, Screen, Scale Factor: 100% (you can change this later if you’re on a high-res display)
    • Display, Screen, Accelerator: 3D and 2D both unchecked
    • Storage: One controller, first item is USB shim, then the hard drive and “Empty” optical drive. The order of those two don’t matter.

After configuring the VM in the UI, close VirtualBox and run the following commands, of which I’ve created a convenient all-in-one script here. You may need to edit it depending on what you named your VM.

These make the appropriate settings to fool OS X to thinking you’re on a real Mac.

Boot the VM and Install Sierra

Alright, we’re ready to boot! Re-launch VirtualBox as an administrator and start up. After a bunch of Unix style text scrolling, you should see the Apple logo appear and begin to load macOS. If not, something’s configured wrong. Read through the above steps and see what you missed. Of course, things may have changed over time, and this tutorial may no longer be valid. Bummer if that’s the case! Much sad. I want you to be much happy.

NOTE: If things appear frozen during boot, wait a minute. In sanity checking this on another machine with a friend, his seemed to be frozen, and then resumed. A watched installer never boils… [terrible joke]

The instructions for installing Sierra are pretty straightforward:

  1. When the installer appears, select the Utilities menu on top, then Disk Utility.
  2. Format the Virtual Hard Disk. I named mine VBox, but that doesn’t matter. Make sure the format is GUID Partition Map and Mac OS Journaled. Do not select the case sensitive option.
  3. When formatting is complete, quit Disk Utility and you’ll be back at the installer.
  4. Select the freshly formatted hard drive and start the install process.
  5. Wait. It took about 20 minutes to install on my 6th Gen Core i7 SSD Surface Book. YMMV.
  6. Keep an eye on the installer. When it’s done, remove the thumb drive. Otherwise, it’ll boot back into the installer. If that happens, wait for the installer to boot so you don’t corrupt anything, then remove the thumb drive, and restart the VM.
  7. When the Mac boots back up, follow the prompts. Do *not* use an Apple account – it won’t let you. Make note of the username – it will be in lowercase – you’ll need that when you enter a username and password for Visual Studio later. Don’t worry about the Apple Account issue, though – this won’t affect your ability to install XCode or use the App Store.
  8. Once setup is complete, shut down the Mac.
  9. In the VM’s settings, remove the USB shim.
  10. OS X is now installed.

From this point forward, you no longer need to run VirtualBox as an administrator. Yay!

NOTE: After configuring OS X, you may be presented with a dialog stating the keyboard cannot be identified. Don’t worry – just follow the prompts and you’ll be all set.

Install Xcode

For OS X to act as a build server, you must have Xcode and Xamarin Studio installed. Let’s install and configure Xcode first.

To complete this step, do the following:

  1. Open the App Store on the Mac
  2. Search for Xcode
  3. Click Get to install it. You’ll need to enter your Apple account credentials.
  4. Wait a while – it’s big and takes a while to install. About 30 minutes on my machine.
  5. Once installed, Launch Xcode, agree to any terms, and let it finish installing components.
  6. When Xcode is finished configuring, open the Xcode menu, select Preferences, then Accounts, and click the + symbol. Enter your Apple Developer Account details.
  7. Great! Xcode is configured! Time to get Xamarin set up.

Install Xamarin Studio

Xamarin Studio handles installing the OS X build agent so you can debug apps with Visual Studio, while performing the necessary build and simulation tasks on the Mac. This is required for licensing reasons, and Apple being a closed system for iOS developers. Boo.

Note: Xamarin Studio may be called Visual Studio for Mac by the time you read this.

  1. First, open Safari – unless you installed something else on the Mac already – and download Xamarin Studio for Mac. This is simple – go to Xamarin.com, and download the installer.
  2. Open the installer on your Mac from the Downloads folder, and click Open when it warns you that it’s an application downloaded from the Internet.
  3. Install everything except Android. You can do Android dev on your PC, so I feel there’s no reason to install it again here. Again, YMMV – do as you wish 🙂 This process can take a while due to downloading and installing many items.
    • Note: I’m not sure if you need Profiler or Workbooks, so I kept them in there. I’m thinking it’s an insignificant difference.
    • Another Note: The installer will say it’s installing Android SDK anyway, not sure why! 🙂 I complained to Microsoft about this – it didn’t make sense to me.
  4. Once Xamarin Studio is installed, start it and make sure it comes up.
  5. Under the Xamarin Studio menu item – which may be Visual Studio by the time you read this – select Check for Updates and make sure everything’s up to date.
  6. Note to Visual Studio 2017 Release Candidate Users: If you’re running Visual Studio 2017 Release Candidate, it [annoyingly] installs and targets the alpha channel of Xamarin. You’ll need to switch to the Alpha channel in Xamarin Studio to match this, otherwise Visual Studio will refuse to compile/build/debug through the Mac instance. A channel switching option is available in the Check for Updates menu to address this issue.

Configure the Mac for Remote Login

In order to connect to the Mac from Visual Studio, we’ll need to open a port on the Mac side. The process is described in this article.

In a nutshell, here’s what you’ll be doing in this step:

  1. Press Windows-Space, which translates to Apple-Space, and type remote login to open the Sharing control panel.
  2. Check the box for Remote Login, and select All Users, or at least ensure your user account is in there. You’re on a private network only accessible by your machine, so I see few security issues here. Behind the scenes, this is opening Port 22 for SSH access to your Mac.

Alright, we should be all configured! Let’s switch back to Windows!

Visual Studio For Mac Tutorial

Configure VirtualBox Networking and Port Forwarding for Remote Debugging

Xamarin Build Ios From Windows

Now that the Mac is configured, we have to tell VirtualBox how to allow your computer to talk with it. We do this by configuring Port Forwarding in VirtualBox.

  1. Open command prompt and type ipconfig.
  2. Take note of the Ethernet adapter VirtualBox Host-Only Network, which may be #2, #3 etc. You want the one with an IP address. Copy that IP address to the clipboard.
  3. In VirtualBox, open the Settings of your VM, and select Network, then Advanced, then Port Forwarding.
  4. Add a new rule. I named mine Remote Access.
  5. For Protocol, choose TCP.
  6. For Host IP, paste in your host adapter IP.
  7. For Host Port, enter 22.
  8. For Guest Port, enter 22.
  9. For Guest IP, go to your Mac, use Windows-Space to search for Network Utility, and type in the IP that appears there.

Note: It’s possible the Guest IP will change from time to time. This is especially true if the Mac isn’t the only virtual machine you run. If you can no longer connect, check whether you need to update the Guest IP.

VirtualBox is now configured! If you want to verify this, you can launch bash shell on your Windows 10 machine and type ssh username@ipaddress, accept the certificate, and enter your password when prompted. If you can type ls and see your Mac’s files, all is good in the world.

Link Visual Studio to macOS

Alright, hard part’s over. Now we need to configure Visual Studio. The steps for accomplishing this can be found at the same link above, or you can just click here if you don’t want to scroll. There’s also a tutorial in Visual Studio.

In a nutshell, here’s what you’ll be doing in this step:

  1. Launch Visual Studio.
  2. Type Control-Q to access the Quick Access Menu, and type iOS Settings. This will take you to the Xamarin iOS settings pane.
  3. Choose Find Xamarin Mac Agent, follow the prompts to ensure you’ve configured everything properly.
  4. In Enter Mac name or IP address enter your VirtualBox host adapter’s IP. If everything’s configured properly, you should be prompted to enter your Mac’s username and password.
  5. If all went well, a lock-like icon should appear next to the IP address, as shown below. If not, make sure the version of Xamarin installed in Visual Studio is the same as that on the Mac. See my note above about Visual Studio 2017 and its Xamarin Alpha Channel issue.

And, Go!

If everything went well, you should now be able to do all your Windows and Xamarin / Mac development on one machine!

Please provide feedback in the comments. Enjoy!

Tips / Updates

  • If you’d like to tweak the video resolution, you can follow this article. The command is:
  • My goal with this article is to build a machine for building a build/test VM. I am not trying to replace a Mac environment for doing lots of work on the Mac side of things.
Active19 days ago

I'm a .NET developer and want to write an IOS & Android app in C#. I've had a read around Xamarin for Visual Studio which looks interesting if not a tad expensive!

Do you need a Mac to debug your code? Do you just need a networked Mac to actually deploy the app to the Store?

Is the best option just to buy a Mac and run Windows with VS in a VM or can I just use my windows machine, write & debug the code in Windows then just hook up to a networked Mac for final deployment?

HardgrafHardgraf
1,1924 gold badges27 silver badges60 bronze badges

6 Answers

Yes, you must have a Mac to do Xamarin.iOS development. The Mac is required for building as well as running the iOS simulator. You can either use it as a build server, and actually do your development in Visual Studio (either in a standalone PC, or on a VM running on your Mac), or you can do your development directly on the Mac using Xamarin Studio as your IDE.

JasonJason
56.5k13 gold badges98 silver badges124 bronze badges

From May 2017, you can develop app without MAC.

Microsoft Xamarin introduce a Live Player. With Live Player, iOS apps can be deployed directly onto an iPhone or other iDevice from a PC running Visual Studio, where the code can then be tested and debugged.

WARNING The Xamarin Live Player Preview has ended. See discussion

See this video: https://www.youtube.com/watch?v=awgZDL1a3YI

Xamarin Visual Studio For Mac

this is Live Player Get start section: Live Player

Note: The final build and submission to the App Store will still require a Mac

Device Requirements

The Xamarin Live Player app supports the following devices:

iOS

  • iOS 9.0 or later.
  • ARM64 processor.
  • Check the App Store for a list of supported devices.
Studio

Android

  • Android 4.2 or later.
  • ARM-v7a, ARM-v8a, ARM64-v8a, x86, or x86_64 processor.

Limitations

There are some limitations on the things Xamarin Live Player can run, including the items below:

  • Android user interfaces designed with AXML files are not currently supported.
  • Some iOS storyboard features are not supported.
  • iOS XIB files are not supported.
  • Custom Renderers are not supported.
  • Xamarin.Forms Effects are not supported.
  • Embedded resources are not supported (ie. embedding images or other resources in a PCL).
  • Limited support for reflection (currently affects some popular NuGets, like SQLite and Json.NET). Other NuGets are still supported.
  • Some system classes cannot be overridden (for example, you cannot implement a subclass).
  • Some platform features that require provisioning can't work in the Xamarin Live Player app (however it has been configured for common operations like camera access).
  • Custom targets and build steps are ignored. For example, tools like Fody cannot be incorporated.
ebattulgaebattulga
5,34317 gold badges73 silver badges110 bronze badges

You can use Xamarin Studio instead of Visual Studio and build iOS application by C#.First install VMware Workstation and then download OS X image and run it by VMware.

Then Install tools on it and enjoy.

Tools :

EDIT : The following links are out dated, You must install Mac OS 10.10 in order to be able to install XCode 6.

iOS Tools that you need:

1) Mac OS X image for WindowsNote: Max OS X Installation Help:http://www.sysprobs.com/easily-run-mac-os-x-10-8-mountain-lion-retail-on-pc-with-vmware-image

2) Mono:http://download.xamarin.com/MonoFrameworkMDK/Macx86/MonoFramework-MDK-3.2.4.macos10.xamarin.x86.pkg

3) Xamarin Studio:http://download.xamarin.com/studio/Mac/XamarinStudio-4.2.1-1.dmg

4) MonoTouch:http://download.xamarin.com/MonoTouch/Mac/monotouch-7.0.4.209.pkg

5) Xcode

Morteza SoleimaniMorteza Soleimani
1,8712 gold badges19 silver badges36 bronze badges

Update 2018

Install VirtualBoxhttps://www.virtualbox.org/

Install MacOs 10.13 on VirtualBoxhttps://techsviewer.com/install-macos-high-sierra-virtualbox-windows/

Create or login with an apple account on the mac

Install XCode 9.0https://download.developer.apple.com/Developer_Tools/Xcode_9/Xcode_9.xip

Enable Remote LoginSystem Preferences > Sharing > Remote Login > Enable for All Users

Configure VirtualBox with an additional network adaptor (host-only)

In Windows > Visual Studio (Xamarin Project) > Pair with mac

Enter the IPaddress of the second network adaptor

Let Visual studio install Xamarin IOS, IOS SDK, additional tools on the Mac

All set up.

VerthosaVerthosa
1,1161 gold badge9 silver badges25 bronze badges

An option is to use a remote service to do this. For example:http://www.macincloud.com

heronsanchesheronsanches

Anybody know that a Virtual-Machine is the solution! but when you want to have an OSX on windows it's not really easy as you just talked about it.it's very important to find best OS ROM.

check it out here.and you have to know that limitation is Apple's doing, not Xamarin's.

Mehdi SaghariMehdi Saghari

Not the answer you're looking for? Browse other questions tagged c#androidiosmacosxamarin or ask your own question.