This article shows how to set up Xamarin.iOS for Visual Studio. It covers the installation process for the Xamarin plug-in for Visual Studio, and discusses the steps for pairing a Macintosh Build Host with Apple’s SDK installed.
Xamarin iOS for Visual Studio allows iOS applications to be written and tested on Windows computers, with a networked Mac providing the build and deployment service.
This article covers the steps to install and configure the Xamarin iOS tools on each computer, so we can build iOS applications using Visual Studio.
Developing for iOS inside Visual Studio lets you:
- Create a single cross platform solution for iOS, Android and Windows applications.
- Use Visual Studio tools (such as Resharper and Team Foundation Server) for all your cross-platform projects, including iOS source code.
- Work with a familiar (for existing Visual Studio developers) code editor, keyboard shortcuts, etc.
Xamarin.iOS for Visual Studio supports configurations where Visual Studio is running inside a Windows virtual machine on a Mac (using Parallels or VMWare), or when a Mac Build Host is connected to the same network as a Windows machine with the tools installed.
Xamarin iOS for Visual Studio accomplishes an amazing feat: it lets you create, build and debug iOS applications on a Windows computer using the Visual Studio IDE. It cannot do this alone, however - iOS applications cannot be created without Apple’s compiler, and they cannot be deployed without Apple’s certificates and code-signing tools. This means that your Xamarin iOS for Visual Studio installation requires a connection to a networked Mac OS-X computer to perform these tasks for you. Once configured, Xamarin’s tools will make the process as seamless as possible.
The system requirements are:
- Windows 7 or higher.
- Visual Studio 2010 Professional or higher.
- Xamarin’s plug-in for Visual Studio.
- A Macintosh running OS X Lion or higher (although we recommend the latest version).
- Xamarin iOS SDK.
- Apple’s Xcode IDE and iOS SDK (we recommend the latest version from the App Store).
The Windows computer must be able to reach the Mac via the network.
Apple Developer Account
To deploy applications to a device or submit them to the App Store, an Apple Developer account is required. The relevant developer certificates and provisioning profiles must be created and installed on the networked Mac before Xamarin iOS for Visual Studio can work. See the Device Provisioning article for steps to obtain a development certificate and provision a device.
Xamarin iOS for Visual Studio enables the creation, editing, build and deployment of iOS projects from Windows. This includes the following features:
- Create new iOS projects.
- Edit iOS projects and cross-platform solutions that also include Xamarin Android and Windows Phone projects.
- Compile iOS projects and cross-platform solutions that also include Xamarin Android and Windows Phone projects.
- Deploy and debug iOS applications, where the app itself runs in a simulator on the network-connected Mac, or a device connected to the Mac.
There are some tasks that Xamarion iOS for Visual Studio currently cannot do:
- Storyboard and XIB files cannot be edited - There is currently no drag-and-drop design surface for iOS in Visual Studio. The solution must be opened in Xamarin Studio on the Mac for user interfaces to be created using Interface Builder or the Xamarin iOS Storyboard Designer. Remember to save the changes so that the
.designer.cspartial class is updated and synchronized with the solution on Windows.
- No iOS simulator on Windows - The iOS Simulator runs on Mac OS X, so it’s necessary to switch to the Mac’s screen when testing on the simulator.
Configuring The Mac
Follow these instructions to install Xamarin iOS tools on your Mac host and to activate your Xamarin license.
Once the software is installed, follow the steps in the next section to configure Xamarin iOS on OS X to allow Xamarin for Visual Studio to connect to it.
Once installed, ensure that you have turned off your firewall (to allow Visual Studio to connect). To do this:
- Go to System Preferences… from the Apple menu:
- Select Security & Privacy in the Personal section:
- Select Firewall from the segment control at the top of the window:
- If the firewall is turned on, click the lock (bottom left) so that you can change the setting, then click Turn Off Firewall.
You may also want to check the Xamarin Firewall Configurations Instructions to ensure there are no additional endpoints you need to whitelist.
Your Mac is now ready to operate as a Build Host for Xamarin.iOS for Visual Studio.
iOS Developer Setup
Follow these links for instructions to setup a Mac for iOS development with Xamarin. These are the same steps regardless of whether you are using Xamarin Studio or Visual Studio - if you’re already a Xamarin.iOS developer then you’ve probably already done these steps:
Once your Mac is configured, it’s time to set up your Windows computer.
Download the latest Xamarin unified installer and run it.
The installer includes a Xamarin Bonjour Service (Apple’s network discovery protocol), which is installed at the end of the process. Installing the Xamarin Bonjour Service requires Administrator rights, so expect to be prompted twice to allow installation as an Administrator.
cmd.exeand choosing to Run as Administrator… and execute the installer MSI on the command line:
Be sure the file name is correct.
The Xamarin Installer will guide you through the steps necessary to install your Xamarin software.
Once the installation is done, Visual Studio is started automatically in the background so you can start building iOS applications right away.
Using a Windows Virtual Machine
Xamarin.iOS for Visual Studio can be run inside a Windows virtual machine on OS X, using applications like Parallels or VMWare.
Parallels and Retina Macbook Pros
When using a Windows Virtual Machine inside Parallels on a Macbook Pro with Retina Display, you should change the Video Hardware Settings to use a Scaled resolution. If you don’t change this setting, some elements of the IDE will be poorly rendered and difficult to use.
After the installation process is complete, there are still a few more steps required to get everything working:
- Link Your Xamarin Account - Ensures that all features you are entitled to are enabled. You can create a new Xamarin Account if required.
- Connect Visual Studio to the Mac Build Host - Visual Studio must be connected to the Mac Build Host before it can work with iOS projects.
- Configure the Visual Studio Toolbar - Lets you easily access Xamarin.iOS features.
Linking to your Xamarin Account
You must link your Xamarin account to your Visual Studio installation to access all the features you are entitled to.
In Visual Studio, go to the Tools > Xamarin Account… menu item to begin:
The following screen will appear, click Login to your Xamarin Account. You will be given the opportunity to create a new account if you don’t already have one:
Enter your Xamarin Account details, or create a new account:
Once you see the ‘finish’ message, return to Visual Studio:
This screen indicates that your Xamarin Account has been successfully linked to your Visual Studio installation:
Connecting to the Mac Build Host
The Configuration Wizard will automatically start when you open an iOS project in Visual Studio after installation. You can update the Mac Build Host settings later from the Tools > Options > Xamarin > iOS Settings panel in Visual Studio.
Mac Build Host Detected Automatically
When the Configuration Wizard opens, it shows instuctions for how to open the Xamarin Build Host on the Mac using Spotlight:
On your Mac, open the Xamarin Build Host, and choose Pair. The Build Host will provide you with a PIN:
Switch back to Visual Studio and choose Next in the Configuration Wizard. If your Mac is correctly configured, the Wizard will list it as a possible Build Host:
Choose your Mac Build Host and click Select. Visual Studio will then ask for the PIN:
Once the machin PIN is entered, Visual Studio will connect to the Build Host and let you compile, deploy and test iOS projects.
To unpair the Build Host from Visual Studio, open the Xamarin.iOS Build Host and click Invalidate PIN:
Visual Studio Toolbar Configuration
You must manually configure the Visual Studio toolbars, as they will be necessary to perform certain operations. First open the View > Toolbars menu and make sure the iOS entry is selected. Choose the menu item as shown in this screenshot - it should be ticked to indicate that the toolbar is visible:
Add the Solution Platforms button to the Standard toolbar, following the instructions below. This allows an iOS Device or the iOS Simulator to be selected when debugging.
- Right-click the Standard toolbar (the one which has the current configuration drop-down saying Debug, Release etc) and choose Customize… from the menu:
- Switch to the Commands tab.
- Select the Toolbar radio button
- Select the Standard toolbar in the list to the right of the radio button
- Scroll down the Controls widget till you see the Solution Configurations widget and select it
- Click the Add command... button:
- Choose the Build category
- Choose the Solution Platforms command and click OK:
- Click Close
Visual Studio 2013
Click the menu button at the right side of the Standard bar:
- Choose Add or Remove Buttons
- Select Solution Platforms
The Standard and iOS toolbars should now resemble this screenshot:
Once the toolbar configuration is complete, you are ready to begin using Xamarin iOS for Visual Studio.
This article presented a step-by-step guide to installing, configuring, and using Xamarin iOS for Visual Studio.
It covered installing and configuring the prerequisite tools on Windows and Mac OS X.