Are You Interested In Using .NET & C# To Make iPhone Apps?

Matthew Campbell, January 1, 2012

Believe it or not, I cut my teeth in programming by learning .NET and C# for Windows computers. The reason I went this route, like thousands of other programmers, is that Windows was used where I used to work. And knowing .NET is like having a key to doing anything you want on Windows computers. For the years I programmed in .NET I did enjoy the experience.

The first thing I asked when I wanted to make iPhone apps was, Can I do this on Windows and/or with the tools I’m familiar with like .NET?

Three years ago the answer was NO.  Today, you have tons of options including .NET, HTML and JavaScript.  You still need a Mac though.  A few weeks ago I sat in on a talk by Mike Bluestein on how to make iPhone apps with .NET using MonoTouch.  Being a .NET veteren I decided to give MonoTouch a go.

First Thing I Noticed When I Tried MonoTouch

So I assumed I could simply download the trial package from Xamarin and jump in (like you would with regular XCode). Of course, as I should have guessed that was not to be the case. After the package from Xamarin finished installing it just ended with no indication of what to do next. It turned out that I need to download a bunch of other open source frameworks first. Not a good start, but I decided to move on – guess I’ve been spoiled by using Apple products now for three years.

So, there were a total of three downloads (+1 if you don’t have XCode yet) before I could test MonoTouch out on my Mac. That being said I was able to get everything installed and running in a about 20 minutes. So, let’s move on from this initial clunkiness.

First Impressions Of MonoDevelop

Keep in mind that Mono and MonoDevelop are open source projects built by the community and not a product like MonoTouch. Since I’ve last looked at Mono years ago I can say that the tools have advanced significantly. What I did first was create a Storyboard based single scene iPhone app. This essentially works in the same was as XCode. Here is the screen I got when I did this (this is the .NET code in the view controller):

All the UI is still handled by XCode so when you click on the storyboard XCode with open up with Interface Builder all set up. It was a pretty trivial task to get my app to say Hello World using a label.

Compared to XCode or Microsoft’s Visual Studio, MonoDevelop seems very basic and not as pretty as us Mac-spoiled Window refugees would like. Still, the .NET code is there and the seems to look as nice as I remember it.  Switching between XCode and another IDE seems tired but it actually works pretty well, especially with storyboards.

MonoTouch

While MonoDevelop and Mono are both open source and supported by the community, MonoTouch is something that you must buy (but you can try for free).  MonoTouch gives you bindings from iOS to .NET and the idea is that you can simply use .NET to access all the familiar iOS frameworks and components like UIKit.

Again, this gives you C# as the programming language and .NET as the platform and so you also some of the .NET standards like LINQ that you don’t get in iOS.

UIAlertView alert = new UIAlertView("UIAlertView C#", "Hi", null, "Cancel", null);
alert.Show();

What is nice about this is that you get .NET’s data storage and web services frameworks so if these are a big part of your workflow then you may want to consider this. This includes SOAP, LINQ and other stuff that you are probably familiar with as a .NET developer and sorely miss as an iOS developer.

Whose MonoTouch For?

Admittedly, MonoTouch is not for everyone.  The main audience appears to be developers in big companies who are .NET experts and want iPhone apps.  So, if you are not willing to learn Objective-C (or your boss is not supporting you) then this may be a viable alternative.  Or if you workflow absolutely requires some of the .NET features then this may be the only way to do.

Bottom Line

In my experience, you should always just go for the native platform.  iOS app development is already a tricky business – why double your chances of something weird happening when you are coding?  Plus, since you need to learn the frameworks the only real gain is that you can avoid Objective-C.  Honestly though, learning Objective-C was not the hardest part of the transition from .NET to iOS and I can’t see how this convoluted workaround is really a good solution.

What Do You Think About Third Party Alternatives To iOS SDK For Building iOS Apps?