Code of Thrones

Writing an application on Mac OS X with Mono C#

I have a windows form application written in C#, and I thought it would be cool if I can migrate it on to Mac OS with Mono, which claims to provide portable C# on both Windows, Linux and Mac OS.

First I installed Mono SDK and Xamarin Studio, and surprisingly found it able to import the visual studio project directly. Then came the disaster. Strange errors came one after another, and most of them doen’t make sense at all. The errors, as figured out later, are almost impossible to fix because of Mono’s poor support for some of the windows form controls such as System.Windows.Forms.WebBrowser and System.Windows.Forms.NotifyIcon.

So I had to give up the UI code based on Windows.Forms and try to find some substitute. Xamarin.Mac seem to be a suitable option, with the basis of MonoMac. Xamarin provides a good Hello World example for newcomer to get started. The tutorial walks through creating a basic Xamarin.Mac application, demonstrating the development toolchain, including Xamarin Studio and Xcode, as well as explaining the basic structure of a Xamarin.Mac application (which is so different from the windows form application).

Developing with Xamarin.Mac is such a headache, because you can seldom find any examples except the Xamarin document. However, the application is based on the same UI controls of Cocoa applications, thus it looks as native as the Objective-C applications.

The application cannot run on a naked Mac without the Mono Runtime, which makes it less attractive as every endpoint user need to install the Mono Runtime to run the application.

Published: April 30 2013

blog comments powered by Disqus