Menu

I’ve recently started investigating mobile development and my first port of call is Xamarin.Forms – a framework that purportedly allows me to write a single codebase but compile for iOS and Android and Windows Phone all in one motion. There are obvious benefits, but Apple doesn’t make it easy. I’m not sure how they are getting away with this, but Apple requires that apps are compiled on a Mac with Xcode and their SDK. However, this doesn’t mean you have to develop the code on a Mac. You can do all your code wrangling on Windows. Visual Studio will connect to the Mac to do the work it needs to. You can even run your Mac headless (no screen or keyboard) once it is set up.

So I went out and brought a nice shiny new Mac Mini. It will cost you about $800 (since you will want one with 8Gb of RAM – trust me on this). Here is how I set my new Mac Mini up.

Create a “Last Resort Login”

When I set up a new machine – irrespective of if it is a PC or Mac – I always set up an account of last resort first. It has a local password and nothing installed on it. It’s an Administrator. It’s not hooked into the Microsoft Account (Windows) or iCloud Account (Mac). I recommend you do the same. You should never need it in an ideal world. You will be glad it’s there if your account goes haywire and you find you need to recover data but can’t log in.

Create your own account and update the machine

Next, I create “my” account. This has all the whizz-bang features of the environment. Mine is hooked into the iCloud login, has access to my iCloud Keychain and I’m setting this up the way I want. Right away, I always upgrade the system to the latest release of the OS, install all the patches and generally get it up to date.

In the case of the Mac, there was a new version of the OS plus new versions of several software packages. It required a reboot. I know – shocking, right!

Getting to this point took me about 40 minutes. The update alone took 30 of those minutes.

Turn On Screen Sharing and Turn Off Sleepy Mode

You need to ensure your mac is available. To do that:

Click on the Apple Icon (top left of screen) and select System Preferences…

Click on Security & Privacy

Ensure the Firewall is turned off. If it is turned on:

Click on the padlock in the bottom left of the window

Enter your password (you will be prompted for it)

Click on the Turn Off Firewall button

Click on the back arrow at the top of the window

Click on Energy Saver

Check the box Prevent computer from sleeping automatically when the display is off

The default settings have “wake up on network access”. I found that this was a little laggy, so I’ll take the hit and have the machine always awake. Note the Schedule button as well. I have my Mac wake up at 8am and sleep at 6pm automatically. This ensures that my Mac is awake during working hours, but goes to sleep when it isn’t needed. I have the good fortune of being able to work on stuff during the working day. You can adjust this so that your mac is available when you are.

If you want to, you can also go into Sharing and turn on Screen Sharing. This will make your mac available via VNC – a competitive remote desktop solution to RDP that is beloved by Microsoft. You will need to download a VNC viewer for your Windows system. I use TigerVNC personally for this. If you are concerned with security, then ensure you set a VNC password. Also note down the IP address of your Mac – you will need it to connect.

Install Useful Utilities

I hate to say it, but neither the PC nor the Mac is really functional out of the box. In the case of the Mac, I need a decent text editor and something to expand archives. For the former, I recommend TextWrangler. For the latter, I recommend StuffIt Expander. Both are free and available on the Apple Store. As always, if you find yourself using them then support the developers and buy the pro editions. BBEdit is the big brother of TextWrangler and there is a Deluxe edition of StuffIt Expander.

Install Xcode and the iOS SDK

Now onto the things you HAVE to install. First up is a 2.6Gb download of Xcode. This is also available from the Apple Store, but you can also download it and install it from a USB key – a good idea if your work place has a better link than you since it is so big. Xcode is the Apple answer to Visual Studio – an IDE for developing Apple things, including iOS developer tools.

Optional: Join the Apple Developer Program

If you are starting to develop, then you’ve done enough. You’ve for Xcode and the iOS SDK on your machine. However, there are two specific things that come with being a member of the Apple Developer Program:

You can test your app on real devices

You can distribute your app via the App Store

If you want to do either of these things, then you need to be in the Apple Developer Program. For an individual, that costs $99/yr. For organizations, it’s even more. I didn’t do this – mostly because I am only intending to learn Xamarin and not actually distribute my apps. If and when I decide to distribute my apps, then I’ll sign up to be a developer.

Install Xamarin Studio

Next on the list of installs is Xamarin Studio. Start up Safari, go to the Xamarin Website and click on Products then Xamarin Platform (or follow my link). There you will find a nice friendly pink Download button. Fill in the nice form, click on the nice blue Download button and the installer will download.

It’s downloaded as a disk image and the Downloads area is in your launch bar – right next to the trash can. Click on it (it will look like a hard drive) to expand it, then click on the disk image file. You can then double-click the installer in the new window. The installer is your basic wizard – it involves a lot of clicking Next. Don’t walk away when it starts downloading. The installer will ask you for your password (my install asked for the password twice). Click on Quit when it’s complete.

Once this is done, you can drag the Xamarin Installer disk (on your desktop) to the trash to unmount it. I would also place Xcode and Xamarin Studio on the launch bar. Click on the finder (left most icon in the launch bar), select Applications, then drag Xcode to the launch bar – the icons will move to allow it to fit. Repeat for Xamarin Studio and Xamarin.iOS Build Host.

Sign Up for a Xamarin Account

You need a Xamarin account to use Xamarin. Go to the Xamarin Web site, click on Log In (in the top right corner of the page) and then select “Create a new Account”. Fill in the form, click on Submit and you are done.

Then go back to your Mac, start Xamarin Studio, click on Log In (top right corner of the window) and enter the credentials you just created.

Start Xamarin.iOS Build Host

Finally, I’m at a point where I can start the Xamarin.iOS Build Host. Just start the application. It will display a window with a Pair button. Let’s wait on that…

Setting up Visual Studio 2015

Now I’m going to turn my attention to the Visual Studio setup on my PC. First off, I’m going to assume you already have install Visual Studio 2015. Next, go back to Xamarin Platform and download the PC installer. It’s practically an identical setup experience to the Mac version. Once it is installed, start up Xamarin Studio and log in – just like the Mac version and with the same credentials. Then you can close down Xamarin Studio.

Now start up Visual Studio. Go to Tools -> Xamarin Account…. You should already be logged in. If not, log in there.

Eventually, you will get to a point where you are asked to pair the computer with your Mac. It looks like this:

Now you can switch back to your mac and click on that Pair button. It will give you a 6 digit code:

Back on your PC, click on the Continue button in the Connect to a Xamarin.iOS Build Host. Your mac should be listed:

Click on your mac, then click on Connect. It will pop up a window asking for the PIN. You can Enter the PIN in the window on the Mac.

Click on Pair. Success! Click on Finish on the PC side, and Close on the Mac side. Leave the Xamarin.iOS Build Host running on the Mac side of things.

Ensuring the Build Host is Available

Let’s face it – stuff happens. Power Outages, shut downs, restarts. All these things move together to ensure our computers are not running all the time. I solve this by three things:

In the System Preferences, Energy Saver – there is a check-box for “Sart up autometically after a power failure”. I set this option.

In the System Preferences, Users & Groups – there is a button for Login Options. One of the login options is “Automatic login” – I set my account as the automatic login.

On the launch bar, right click on Xamarin.iOS Build Host, select Options and Open at Login.

With this set up, my mac is always running. When it starts, it automatically logs me in, and when I log in (including automatically), the build host is automatically started. I don’t really have to worry about it.

I also have screen sharing turned on for those times when the build doesn’t work. In that case, I take a peek at the VNC Viewer and ensure that I am logged in and the build host is actually running.