Build And Debug Xamarin iOS Application On Windows Machine

Introduction

Xamarin is great technology for cross-platform mobile application development. You can create, build, and debug iOS applications in Windows machines, using Visual Studio. In this article, I will explain what are the ways to debug and build Xamarin.iOS applications on Windows machines.

Xamarin and Microsoft are giving very great solutions for creating and debugging iOS applications. But, an iOS app cannot be created without Apple Compiler, and it cannot be deployed without Apple certificate and code-signing tools. Please read below where I have explained about software requirements and steps.

Software Requirement

You can install the following software from Windows and Mac machines.

Software

Windows Machine

  1. Windows 7 or higher (7, 8, 8.1,10 +)
  2. Visual Studio 2013 professional or higher.

Note
    You cannot use the Xamarin plug-in in Visual Studio Express editions.

    Mac Machine

    1. A Mac running OS X El Capitan (10.11) or higher
    2. Xamarin Studio 5.10 or higher with Xamarin.iOS SDK
    3. Apple Xcode(7+) IDE and iOS SDK from https://itunes.apple.com/us/app/xcode/id497799835?uo=8&at=11ld4k

    It greatly helps if your machines are physically near to each other, because when you build and run on Windows, the iOS Simulator will load on your Mac.

    Build and Debug iOS Applications

    I have explained about basic Xamarin.Form application creation in my previous article. You can refer to and create basic Xamarin.iOS or Xamarin.Form application. 

    After creation, Visual Studio will prompt you to prepare your Mac to be the Xamarin build host, using the below 3 steps.

    Mac Machine

    Step 1

    On the Mac Machine, select “System Preferences”.

    Software

    Step 2

    In System Preferences, click on “Sharing”.

    Software

    Step 3

    In Sharing, turn on the Remote Login and change "Allow access to All Users or Only these users" and add a user.

    Software

    Windows Machine

    Step 1

    In the Visual Studio, you can click on “Connection Indicator“.

    Software

    Step 2

    Select your Mac name from Mac agent window and click on “Connect”.

    Software

    Step 3

    Enter the Mac username and password and click on "Login".

    Software

    After successful connection, the color of Connection indicator will change to green. If its connection is on low bandwidth, it will change to orange (it’s not recommended for debug applications).

    Software


    Your app will compile and execute, but you won’t see it running on Windows. Instead, you’ll see it on your Mac build host.

    iOS Simulator Remoting

    In Evolve 2016 Conference, Xamarin announced iOS Simulator remoting that will soon allow you to interact with apps running in Apple iOS simulator as if the simulator were running on your Windows machine.

    For iOS Simulator remoting also, you need to follow all the above steps and below steps as well.

    Windows Machine

    Step 1

    Download the installer and install on your Windows computer.

    Step 2

    After installation, in Visual Studio, go to Tools > Options > Xamarin > iOS Settings and tick the box for Remote Simulator to Windows.



    Output

    Now, build and run the solution and iOS simulator will open in Windows machine.

    Software

    Issues and Resolution

    1. Issue 1

      Error cannot resolve reference: C:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/Xamarin.iOS/v1.0/Facades/System.IO.FileSystem.Watcher.dll I1Vector.iOS

      Resolution

      This issue happened because of different versions of Xamarin.iOS on Windows Machine and Mac machine. After updating xamarin.ios, this problem will get resolved.

      How to Check xamarin.iOS Version Number ?

      In Windows machine, go to Visual Studio >> Help >> About Microsoft Visual Studio.

      Software

      In Mac machine, go to Xamarin Studio and select Xamarin Studio Menu >> Click About Xamarin Studio >> click Show details.



      How to Update Xamarin.Ios in Mac and Windows?

      Mac Machine
      Go to Xamarin Studio and Click on “Check for Update” and Update.

      Windows Machine
      Go to Visual Studio >> Tools >> extensions and updates.

      Sometimes, it won’t be available in update the list. if it’s not available, go to Control Panel >> Uninstall program >> Select Visual studio, and click Change option and update .

    2. Issue 2

      Mac Agent can't connect after update.

      Starting connecting to Mac machine. The Xcode license must be accepted in order to be connected and work against the Mac.

      Software

      Solution

      1. Go to Xcode >> Preferences >> Location.
      2. Check if "Command Line Tool" set or Select XCode version.
      3. Run sudo xcodebuild -license in terminal.
      4. Xcode license must be accepted. Press Space bar and press q.

    3. Issue 3

      iOS simulator does not display on Windows.

      Solution

      1. Check Windows and Mac firewall rule or disable, and test the application.
      2. You need to make sure that Xcode is installed in Application Folder. If it’s not, you need to change the path of Apple SDK in Visual Studio.

        Software


    Similar Articles