Cross-platform mobile development

This post is about my thoughts on C#, Xamarin and cross-platform mobile programming in general. Originally, I wanted to talk exclusively about C# and it’s significance in modern mobile programming however I couldn’t resist covering the topic from the beginning. If you are only interested in C# and Xamarin , click here.

Cross-platform mobile development

So you love technology, you enjoy your iPhone/Android/Windows device, you know how to program and you have a ground-breaking-kick-ass-never-seen-before-will-turn-the-world-upside-down idea for a mobile app, what next? Answer is simple: go make it!! But make it how? Isn’t your idea worth sharing with the whole world? or is it worth only sharing with someone who owns an iPhone (assuming you do swift/objective-c) or an Android phone (Assuming the you breath Java like most of the world) ? Do you write it for one platform first then rinse and repeat every single ounce of effort for the next platform? IMO, once you start pondering these questions, you are getting really serious. And once you start getting really serious, you will either wish you have an endless supply of time and developer friends or you start researching cross-platform mobile development. For me, obviously the solution was to take a stab at cross-platform mobile development.

How to start?

In this day and age, there are multiple approaches to go about cross-platform mobile programming. None of them are perfect, but each one can provide a great value if used within it’s realm of power. If you are not familiar with them, no worries, we will cover briefly two of the more popular approaches to cross-platform mobile dev ; then we will dive a bit deeper to the one I use.

Approach 1: Use web technologies

This is currently possible using the PhoneGap or Apache Cordova technologies. They share the core code base between them however the core code was given to the Apache foundation to allow more capable handling of it, which is how Apache Cordova was born.

PhoneGap and Cordova rely on HTML, CSS and JavaScript as a common stack to construct cross-platform mobile apps. I personally only touched this platform once, when I was learning Meteor -which has very nice integration with Cordova- and I was honestly impressed by how my web app magically transformed into a mobile app.

A typical concern with this approach is that it’s performance lacks when the app is complex (need a lot of computations, UI fanciness..etc) , it also doesn’t always provide a native looking UI experience. If your objective is to get an app to the market as soon as possible, the app is not complicated, you love and breath JavaScript and you are not bothered by less snappy UI  then you will love this approach. It could also be really good for rapid prototyping.

Long story short, If you are a JavaScript developer and would like to explore both Meteor (the new sweetheart of the web dev community) as well as Cordova, I strongly recommend you go through their tutorial.

Approach 2: Use C# and Xamarin

C# is a beautiful language. You can love or hate Microsoft, consider them the arch enemy of free software, but there is no denying that C# is a very powerful and elegant language capable of constructing modern sophisticated software. There is also no denying that C# is becoming more free and open than anytime before since it’s inception which greatly amplifies it’s potential.

C# is the type of language that comes across as another Java at first, then it grows on you over time. Once you start using it’s fancy features like LINQ, TPL,  Anonymous functions,  async & await, you just don’t wanna go back.

Xamarin is the result of an effort to bring C# to the forefront of cross-platform mobile development, it is based on the Mono project. Mono is the original effort to make C# free and cross-platform amongst different operating systems, it helped make C# an option beyond Windows. Originally, mono was treated like a second class citizen by Microsoft, however – as per today- it became Microsoft’s new buddy due to the changes in the strategic direction of the company.

Xamarin takes Mono a couple of steps further and it makes C# an option to build cross-platform mobile apps that are closer to native mobile apps than any other solution out there at the moment. Unlike Mono however, Xamarin is not entirely free, you need to pay a monthly license fee if you would like to use it’s advanced and business features. However, that licensing fee is on the same league as a cable TV monthly bill or a smart phone plan,  so basically it doesn’t begin to compare to the cost of hiring a team of full time objective-C/Swift or Java engineers to get your app running on the next platform.

There is a free edition for Xamarin  called starter edition, however, it falls short once you start referencing DLLs in your project so my advise is to start by trying out the starter edition then if you really like it then trying Indie won’t hurt which is the next edition (currently 25/dev/platform as per now).

To get started in Xamarin cross platform, check their detailed tutorial here. The tutorial is more than sufficient into getting you well in your way to hack mobile apps in C#. I started the journey already and here are some fun points that will make your journey smoother:

  1. Even though you will be building mobile apps in Xamarin, you still need to have an idea on how an Android and an IOS app are constructed, there are specific Android and IOS sections in the tutorial along with the cross-platform mobile section
  2. Currently, to build cross-platform mobile apps in Xamarin, you need a solution that includes: an IOS UI project, an Android UI project and a shared project that handles all the plumbing underneath (Explained here)
  3. There is an attempt from the Xamarin guys to unify the UI efforts via a new offering called Xamarin Forms, however it is still ramping up
  4. You can use all features of C# up to the 5.0 specifications. Meaning you have full access to TPL, LINQ and most of the fun stuff. I think the only noteworthy feature that is missing is probably the Elvis operator
  5. You will probably need to implement database access, instead of writing boring SQL queries, try using the sqlite-net ORM
  6. If you need to do REST API calls, checking out RestSharp will definitely be worth your time
  7. For fancy UI controls and some swag, check the Xamarin component store, most of the useful stuff are free. You use Xamarin studio to get a component and it typically extracts it as a DLL with a reference
  8. Xamarin studio will be your best friend unless you decide to pay 83/month/user/platform for Visual Studio integration. It’s not as fancy as Visual Studio however it is not bad either

Basically, this was an overview of cross-platform mobile development. Particularly in C# and Xamarin. There still may be cases where you need to go all the way native like very demanding game engines. However, for most of your typical mobile apps, C# and Xamarin are most definitely worth exploring.

5 thoughts on “Cross-platform mobile development

    1. I am actually looking forward to what Go mobile can offer 🙂 , it will take sometime though before it reaches the maturity of other cross platform solutions. However, once it gets there, it will be an unstoppable force!

Leave a Reply

Your email address will not be published. Required fields are marked *