I just published my newest iPad app and since I used Xamarin I’d like to share my experience. I already published 2 other apps for iOS using plain Objective-C and Titunium SDK, this time I wanted to try something new and I opted for Xamarin. As a .NET developer the switch is really simple and by just using C# you feel immediately at home.


Let’s start from the IDE: Xamarin Studio feels like a crossover between Visual Studio and XCode and in my opinion the operation is a success. If you only know one of them you don’t have to start from zero and if you happen to have worked on both IDEs everything is in the right place.

C# support (Linq)

As far as I used Xamarin I can say that C# 5 is fully supported. One thing of .NET that I love is Linq because using it the code quality and readability is simply amazing. It impressed me so much being able to use it for my iPad App. Other common features that I use like extension methods are there and work as expected. It’s also interesting to note that the Task library works great and using it to communicate asynchronously with a remote server makes the life a lot easier.

Designing the GUI

Designing the GUI with Xamarin Studio is a step back in the, not so old, days where Interface Builder was a separate application. When you open a XIB XCode is launched and you do all your work there (storyboards are also supported). I read that the new alpha of Xamarin Studio has an integrated GUI designer but I didn’t actually tried it.

Web Services

Almost every app that I used required some form of remote call. During this month I tried two of the most common ways to call a web service. The first that I tried is using SOAP: this feature integrated within Xamarin Studio and generates everything you need from a WSDL (just like Visual Studio). It worked perfectly but I find that SOAP has a big overhead and I decided to try JSON. My biggest issue was to find a way to map a reply to a C# object. Fortunately John Sonmez (@jsonmez) wrote a tweet the same day about json2csharp.com and my issue was resolved: you just need the write the service URL or JSON reply and json2csharp translates it to a series of C# classes that you can import in your project. Once that you created the classes you need a lib the write and read JSON: the best way is to use JSON.NET: it’s blazing fast and you implement it in 2 lines of code (http://james.newtonking.com/pages/json-net.aspx). On the server side I’ve chosen PHP and even there I found easier to write a JSON service than using SOAP. In the end there’s no reason not to use JSON to communicate with a server: it gets the job done, it’s fast and it’s easy.


Once that the GUI is in place and the Web Service is configured the last step is to store somewhere the models we downloaded. If you worked before with Objective-C you know that the only ways to store an object is through Core Data or NSCoding. Core Data is great but the model needs to be defined in a particular file and I don’t think that it’s really flexible if you need to save an object that comes from a web service response. NSCoding on the other hand is really flexible and fast but you need to define the serialization by hand. Xamarin offers the best option that I’ve seen so far and it’s: SQLLite-NET. The ease of use it’s impressive: just download the source and you are ready to go. Modify the models with the PrimaryKey attribute above the right property and in the AppDelegate you can add an initialization code similar to this:

using (var conn= new SQLiteConnection("Path/to/DB"))

Now the database ready is to work. Adding a row is really easy:

using (var conn= new SQLiteConnection("Path/to/DB"))
    conn.Insert(new Model());

And querying a table is even easier:

using (var conn= new SQLiteConnection("Path/to/DB"))
    conn.Table<Model>().Where(x => x.Age > 30).OrderBy(x => x.LastName)


Notice that I used Linq (method chains are supported too) to generate the query, in my opinion this is the killer feature of SQLLite-NET.


Xamarin offers a 30 day trial and there’s enough time to evaluate the product. Once the trial is finished the only option is to buy an indie or enterprise license. There’s a free license but you can do nothing with it due to it’s limitations: as soon as you open a “real” project you’re asked to upgrade so don’t count on it.

Code reusability

After the iPad app was published on the App Store I noticed that the marketshare is vastly inferior to the iPhone and I decided to offer also an iPhone version. After reading a couple of articles on internet I thought that it was a complex and long task but now that I finished I can say that it took only 4-5 hours to port the current version. The trick is quite simple: open your solution, add a new iPhone project and link all the common files like your models (when you add an existing file you’ll be asked if you want to copy, move or link the resource). Linking a controller requires a little more of effort because some interactions are device dependent. I resolved this issue by simply using an IPHONE macro and let the compiler handle all the work. The port was so fast that in the same time I was able to produce a lite version using the same workflow.


It took me one month to develop my app and if I compare it to my previous app written in Objective-C (Gluten Free Switzerland) I can say that I’m more efficient with Xamarin. I actually liked to work with Objetive-C (I don’t like XCode but this is another story) but I think that I’ll switch to Xamarin for my future side projects.