简体   繁体   中英

how to connect to remote mac with xamarin/visual studio?

Just installed Visual Studio Enterprise 2017, hoping to use Xamarin to develop iOS apps, which I have abandoned in the past due to connection issues with Xamarin.

No matter what I do, Xamarin will not reliably connect to the Mac on the network. It did connect once but, suspecting my old Mac is too slow to avoid timeout issues with Xamarin, I rented a cloud Mac from MacInCloud.com. Xamarin still won't connect to the remote, even though I can SSH to it via Putty.

Does anyone have a system that works reliably, or know of a good way to troubleshoot this? Xamarin error reporting and logging does not seem to help in any way.

Take a look at this example in xamarin developer page :

https://developer.xamarin.com/guides/ios/getting_started/installation/windows/connecting-to-mac/

Windows Setup Make sure to install Xamarin tools on your Windows machine.

Connecting There are two ways to connect to the Mac build host:

On the iOS toolbar:

Or by browsing to Tools > Options in Visual Studio, selecting Xamarin > iOS Settings and clicking the Find Xamarin Mac Agent button:

Navigating either way will lead to the Mac Agent dialog, illustrated below:

This will display a list of all the machines that have either been previously connected and are stored as known machines, or machines that are available for Remote Login.

Select a Mac by double-clicking on it to connect to it. The first time that you connect to a Mac, you will be prompted to enter your Mac user credentials (which must be an Administrator account) to allow the remote connection:

The agent will use these credentials to create a new SSH connection to the Mac. If it succeeds, an SSH key will be created, and will be registered in the authorized_keys file on that Mac. On subsequent connections the agent will use the username and key file to connect to the most recently connected known build host.

Note: You must use the username and not the full name when entering your credentials. You can find this out by using the whoami command in Terminal. For example, from the screenshot below, the account name will be amyb and not Amy Burns:
When a connection has been successfully made, it will display in the Host Selection dialog with a connected icon next to it, as illustrated below:

There can only be one connected Mac at any one time.

Each machine in the list, whether connected or otherwise, will display a context menu on right-click, allowing you to Connect, Disconnect, or Forget the Mac as needed:

If you choose to Forget this Mac, you will need to re-enter your credentials to connect to it again.

Manually adding a Mac In certain circumstances, you may wish to manually add a Mac if you cannot see its mDNS name listed in the Host Selection dialog. To do this, follow the steps below:

Locate your Mac's IP address by either browsing to the System Preferences > Sharing > Remote Login on your Mac:

Or, if you prefer to use the command line you can find out your IP address by entering ipconfig getifaddr en0 into Terminal (Note that depending on the type of connection the variable might be en1, en2 etc.):

Return to Visual Studio and in the Host Selection dialog, select Add Mac...:

Enter the IP address of you Mac into the Add Mac dialog and click Add:

Finally, enter the username (not full name) of your Mac admin account and the corresponding password:

Once you click Login, Visual Studio will log into the Mac machine using SSH and will add this Mac as a known machine.

Command Line Support The new agent also supports building a Xamarin.iOS configuration from the command line. To use it, you will need to pass the following required parameters to MSBuild:

ServerAddress – The IP address of the Mac server. ServerUser – The Username (not Full Name) to be used to log in to the Mac Server. ServerPassword – The Password used to log in to the Mac host (optional). The ServerPassword parameter is not required.

Instead, the first time a password has been passed, either by using Visual Studio or the Command Line, for that particular Windows, Mac, and user configuration a key pair will be generated and stored on the Windows machine for future use. It will be located in %localappdata%\\Xamarin\\MonoTouch\\id_rsa. If you do not pass the ServerPassword parameter, the id_rsa keyfile will be used for authenticating.

An example command to connect to Mac 10.211.55.2 using xamUser account with password mypassword is shown below:

C:\\samples\\App1>msbuild App1.sln /p:ServerAddress=10.211.55.2 /p:ServerUser=xamUser /p:Platform=iPhoneSimulator /p:ServerPassword=mypassword

Have had same problem since I upgraded to VS 2017. Two things happened just now:

  1. Upgraded my Macincloud MacOS to Sierra. Still couldn't connect.
  2. Noticed an Update to VS 2017. Installed it.

Now I can connect the Mac Agent and run simulations on the Mac.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM