iPhone Development with C# and .NET
Wednesday December 30th 2009
Well, it’s been a year to the day when I decided to crack on with some iPhone development, and what a year it’s been. Busy is certainly one word that would sum it up. Having plenty of work, especially at a time when many are suffering the effects of a tough financial climate, is something always to be grateful of, but sometimes it can hamper other goals.
So how far did I get with Objective-C and iPhone development? Well, I did get some done, and I am certainly a mile up on where I was a year ago, but I haven’t got anything quite completed. It’s been a learning curve for sure, but a good one.
I’ve got my Apple Developer account setup, under my new business name of side lane studios, and have plenty of app ideas lined up and ready to take shape, the first of which I was planning on completing in January. It’s about 50% complete at the moment, so I was going to give myself a window to knuckle down with it and submit it to Apple for inclusion in the App Store. Then I came across MonoTouch and everything changed.
Now for as much Objective-C as I’ve learnt over the last year, it’s still nothing in comparison to my knowledge of .NET, which is only to be expected really after having been programming with the .NET framework for over five years. So which is why, when I came across MonoTouch I took a good hard look.
Mono is a cross platform, open source implementation of the .NET framework, which I have been aware of for some time. The Mono framework itself allows for the development of applications using .NET languages including C# and VB.NET which are binary compatible with the Microsoft .NET framework.
What this means in short is developers with .NET development skills can write and deploy applications for Windows, Linux, and Mac OS X, using their existing skillset. Generally this is carried out using the open source IDE MonoDevelop.
Now, Novell, who is the main sponsor behind the Mono project, has released MonoTouch which allows for the development of applications for the iPhone using the Mono framework, in C# 3.0.
There are some caveats however. MonoTouch only exposes a core subset of the .NET framework, but on the other side of the coin, does also provide a binding of the iPhone Objective-C APIs into C# APIs allowing access to much of what you have access to when using Objective-C directly. The binaries it produces – whilst are iPhone native and don’t use JIT compilation as other .NET apps would – are larger than those produced using Objective-C and Xcode.
Also, while the Mono framework and MonoDevelop is free, MonoTouch is not. An indy licence will currently set you back $399 (about £240 at today’s exchange rates), which isn’t small change. Whilst some may grumble about this, if you’re using it in a business environment, then it’s a small price to pay for higher productivity. There is an unlimited use evaluation version available however, which limits you by only allowing deployment to the iPhone simulator only.
It is also worth noting that MonoTouch is a pretty new product, and is being heavily worked on. Remember, this is a commercial product, with which comes support as well as a very active community.
Also, MonoDevelop, whilst is a very good IDE, isn’t Visual Studio. Don’t get me wrong though, it has intellisense, step-through debugging, and built-in SVN support, which is all great. Also, I have to say its Interface Builder integration is way better than Xcode itself. But again, it is being actively developed and is coming together all the time. As far as cross platform IDEs go, it’s certainly the best I’ve come across so far.
There has been some comment regarding it’s acceptability with Apple, and apps getting into the App Store, but given that the binaries are native iPhone binaries and are compiled using AOT (Ahead Of Time) compilation (also known as plain old fashioned compilation to us old boys), there is no real reason over any other app why an app should not be accepted just because it’s been developed using MonoTouch. There are some apps already in the App Store that have been developed this way, not to mention many Unity games, which itself is based on the Mono framework.
Whether MonoTouch is the way to go for you is up for debate, and it is certainly a hot one at the moment, as I found on this Stack Overflow question.
I’ve been playing around with it for about a week now, and after a few days mucking about and reading tutorials, the app I’ve been working on in Objective-C was rewritten in a mere few hours using C#. Alright, it’s not finished yet, but with my existing skillset I know how to finish it, and will be able to quicker.
Some purists may complain that iPhone apps must be developed in Objective-C, but there really is no justification for that.
So if you’ve got .NET skills and fancy putting together iPhone apps then MonoTouch could be the tool for you. You’re still going to need a Mac and an Apple developer account, but can leave Xcode at the door.