다음을 통해 공유


Build and Debug Xamarin.iOS Application on Windows Machine

Introduction:

Xamarin is great technology for develop cross mobile application development. You can create, Build and Debug iOS application in windows machine using Visual Studio. In this article, I will explain what are the way to debug and build Xamarin.iOS application in windows machine.

Xamarin and Microsoft giving very great solution for create, build and debug IOS application on windows machine using visual studio. but, it cannot do this alone, an IOS app cannot be created without apple Compiler, and it cannot be deployed without apple certificate and code-signing tools. Read below I will explain about software requirement and steps.

Software Requirement:

You can install following software from Windows and Mac machine.

https://lh5.googleusercontent.com/UNaXOypY3pcocBTtLdlyXrt5jvHhxk68DAsAQPjQ3xj-PNWrCxQ6z34dHwLGrpcUL-IkJp_lfWEFxkDxplVZ66qVb8BkqeFcrg3Bvm7P_KmIiBZw3fSbqNPIM1idv9VvZv9lRsgLudh3RU0Eww

Windows Machine:

  1. Windows OS 7 or higher (7, 8, 8.1,10 +)

  2. Visual Studio 2013 professional or higher.

    1. Download Update Visual Studio from here

    2. VS 2015 ++ included xamarin .

    3. If VS 2013 , Download Xamarin for Visual Studio from here

    4. Note: You cannot use the Xamarin plug-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 here

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

Build and Debug iOS Application:

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

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

Mac Machine:

Step 1: On the mac Machine, Select “System Preferences”

https://lh6.googleusercontent.com/wFSedBFKqSoka1KJDZCWr7fMYt_d28bxaNWZkPrNVEXISWS0IymDXOC2L1fGcjAH3lrShMxUHq9ruR-ScD5O2NKgxbAGkoLufdh9xePc7jgy0V9dpZJuKrDxm4V2SkebKQ9Q5sF9jR_kaPa55w

Step 2: In System Preferences, Click on  “Sharing”

https://lh4.googleusercontent.com/YX8gEqJ2WZSSAHp5jdHi8Vfdv1MTmEYRcQn8TlrrzN_66nYAjc0GHg4M3amvdNzuNUaViH6e4876nDVTZzZYUv9N-EH4DZNldOgdBJDEDF39jsdht-rZZKhVU2pDGUQ2N0-0bG9eJTsyr_1eXg

Step 3: In Sharing, Turn on Remote Login and Change Allow access to All Users or Only these users and add a user.

https://lh6.googleusercontent.com/JAbsUHHHemJHoI9Mhmp_JEcNRPo4-cZ23wcefZP1vX0zUjRjW4WNB70vgRWmGLq2_2edWRJ2YyFSMtIOlCq7-5KxpVQAZ50bsak9-xO8IPcD9TJI23Vers6GCgsE7svX3E5Zsky9ztks8DKJSA

Windows Machine:

Step 1: In the Visual Studio, you can click on “Connection Indicator “

https://lh3.googleusercontent.com/ObJ6Zl1QcXjtfzPH3FLRw4POSYA2fj6siJ2xTFnsnWMSiX8IvsPsFI8yPF4BsPrEG6ahIz7nvxuw1nvJ2X-bjwKAPr3o4e4Jx-G4ixRAq_NCssMKyNxKaAHW7nMbGFisUQ3FSk2vmxt37AeuUA

Step 2: You Can Select your mac name from mac agent window and click on “connect”.

https://lh6.googleusercontent.com/DQxYQ8eOwqpXjP39Znqa6cfEU2euApfoDzVz_zL9Y6yqSZz74FosIYJFwOM1mnDr2Y8o1-acbHvepAybT7aNqpxvcVwSqm0QFvI9tAShzQIUgSkjsSZdke0LPzAVRXa1sqZXLVqPlBKLqiVcig

Step 3: you can enter mac username and password and Click on Login .

https://lh6.googleusercontent.com/NLoEEjwSW9KHN49zsI44C8Rtik2WgJjifHQYwd9ek1CWZHDDTWbyNsKUSwnrrNpScB93aBKKlNqJu49lwFw33VgA5ff8W7QuTkBFocakCrlbhydakvrl01AYVDJ63lGOcdibm32Yqqal3YlUBw

After connection, Connection indicator color will change to green, If its connection is very less bandwidth means it will change to orange color (it’s not recommended for debug application)

https://lh6.googleusercontent.com/CwLA0_91zan9lTObktdrEuft6S-Pxsy5ofsm1VcZOs4PzJVv_7eoUeA5QSuXhKtGqquegJUTqkdNP0oWA4mTikG7Px0RGFGPCxRTCjYnkoLJxwo-9LZlK5dZvSE_u248RDjX6HPNRbGKC0BK1w

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:

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

iOS Simulator Remoting also you need follow above all the steps and below steps as well

Windows Machine

Step 1: Download the installer and install on your Windows computer

Step 2: After install, In Visual Studio go to Tools > Options > Xamarin > iOS Settings and tick the box for Remote Simulator to Windows:

https://lh6.googleusercontent.com/8yoopA7mRbOLtAgiealGwN5FVSKgzwXfX_eFVayLHFVay8IXV_q1tLkRl-dhhhrqfCGZMTu4WHWssAeh5mE-fGTlG5v0JRJspzFUR1Nl4rwoTHcFw36VJWdd0fS1O-Cga5n00WKAgSlyCo-dsw

Output:

Now build and run solution and ios simulator will open in windows machine

https://lh6.googleusercontent.com/Pw1wOFZiiElBOPN2J9RDM3-3tu2H8CECX02tlKVHfby_CXPagd6zBBtmSZ0ZL2fKKidFk5TDwU63uzucs4h2x0BicvaOSqUIv7aKfGVq00wSmZ9kiAcGD5UkdPQtm6JqlWKopEqZOJwngKMiqw

Issues and Resolution:

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

https://lh4.googleusercontent.com/LnIGWxxFfYHKgLKtVsMd0RP5ie92qmCSqGlF_or4VYPrRsDAoZL9pFnF_4d0CyhA1kDrwngHMl1CjI594AAhDN8VTFxHZ85IOFS0MG4dqp-GF4wl-XrjstzavPBR2u3xc9Z60ztXABqu6hJWog

In mac machine, Go to Xamarin Studio ➔ Select Xamarin Studio Menu ➔ Click About Xamarin Studio ➔ click Show details

https://lh3.googleusercontent.com/T3JzfIJte-8AZP2Vwm2Ikoy71eRylJW0JtJjDwfIRIwXXxiZ9V-fcWFZYl4erTCFUmnjjU_audojv1TfLH373Al-zgrZi5PpNimv-nQZJqkmzlVSIukKaMoQDSVWE-Bl6VzX_3gzrKk5np7SwA

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.

Some time it won’t available in update list. if it’s not available, go to control Panel➔Uninstall program  ➔ Select Visual studio ➔ and Click Change option and update

Issue 2: Mac Agent can't connect after update:

Starting connection to mac machine. Xcode license must be accepted in order to be connected and working against the Mac

https://lh6.googleusercontent.com/Umc-dlh2UBj-yi5qLgfApd7x5p7ffJ768_w60KCCVSxKRbiyofvHFfXW3Sp2wiOWbluwmnO4N0Q_x_4Qd6aJmFOCM_ZkWtEm8gIZ2aGVZ3MAaWB4lQSOaEfXa04u4M5BcJhZznDL2uklzDnVJw

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

Issue 3: iOS simulator not display on Windows

Solution 1: Check Windows and Mac firewall rule or disable and test application.

Solution 2:

You need make sure xcode installed in Application Folder. If it’s not ,you need to change in visual studio Apple SDK path

https://lh3.googleusercontent.com/WhQVRr08vqugC1U7amKu79mMqQ6reWJt4vZCqnuVPJQSMuuwUxXhCnnwuYeoaXvV_3y6k_0MYSTMiAXBI8fca5kS75Hextn7cjNe6E4sxKBs33SvGBoO77XVVV1HZtdPOUvXqRaETiC4vuD2FQ