Cross platform mobile development

Which Cross Platform Mobile Development Platform Should You Choose?

I’m in the unique position of having developed with almost all of the major cross platform mobile development solutions.

I’ve published courses for Pluralsight on:

After working with all these different solutions and investigating others, I thought I would publish my thoughts on each of these choices and the differences between them.

I’m mostly going to focus on Android and iOS because even though there are other competitors, those are the only major players that exist at present.  Everyone else has a relatively tiny market share.

Native development

The most obvious way to build mobile applications is to use the native tools that come with the platform.

For Android, it is Java and either Eclipse or the new Android Studio, along with the Android SDK.

For iOS, it is Objective-C and XCode.

2013 06 28 12 46 50 thumb Which Cross Platform Mobile Development Platform Should You Choose?

For Windows Phone it would be C# and Visual Studio.

I built my first mobile applications for iOS and Android natively.  I started out with an Android version of my application and then ported over most of the code and design to iOS.

This was a fairly difficult process and I did not have the ability to share any code. I had to learn both platforms along with their SDKs and I had to learn Objective-C, because I didn’t know Objective-C or anything really about Mac development before I started writing my first iOS application.

In general, I wouldn’t recommend this approach because you are going to waste a large amount of time maintaining two completely separate code bases and you really don’t gain much by using the native tools.

However, I would recommend anyone seriously thinking about cross platform mobile development  to at least develop a simple app natively in both Android and iOS.  The reason for doing this is because it will make it easier for you to understand what is going on under the abstraction layer that a cross platform mobile development solution will provide you and it will help you to see the value or lack of value in a cross platform solution.

Xamarin Tools

The Xamarin tools basically allow you to develop an Android or iOS application with C# and share a good amount of the code.

2013 06 28 12 49 18 thumb Which Cross Platform Mobile Development Platform Should You Choose?

When you write an application using the Xamarin tools you are basically using an abstraction on top of the real SDKs for iOS and Android.

What this means is that you will end up with a fully native application with a fully native user interface on each platform.

This also means that you will be limited to some degree in the amount of code you can share between the platforms.

Typically when I develop an application using the Xamarin tools, I will build a core of the application that will be shared code and have the iOS, Android, and even Windows Phone versions of the application depend on this core library.

With this approach you may be able to reuse somewhere around 60-70% of your code without even trying very hard.

But you can take things further and either develop your own abstractions using an architecture like MVC or MVVM to make it so the only code you are not reusing is just the actual views themselves, or you can use a framework that does this for you like MVVM cross.  This approach is, of course, a little more difficult to get started with but can provide a much higher percentage of code reuse, perhaps around 80-90%.

As for the tooling, the Xamarin tools are awesome!

Xamarin has its own IDE called Xamarin Studio.  This IDE is cross platform and is very well designed and easy to use.

The Xamarin tools also have a plugin for Visual Studio which allows you to develop your application in Visual Studio.  You can even develop an iOS application from Visual Studio, but you still need a Mac to perform the build.  (The tool uses a remote call to the Mac to perform the build.)

Xamarin also recently introduced a component store which makes it easy to find reusable components directly from Xamarin Studio and plug them into your application.

Books:

PhoneGap

PhoneGap is probably the next most well known cross platform mobile development solution, but it is also somewhat confusing.

2013 06 28 12 51 06 thumb Which Cross Platform Mobile Development Platform Should You Choose?

PhoneGap is basically a set of JavaScript APIs that allow you to access the native capabilities of your device.  It also is a wrapper that lets you build a web application that is locally installed to the device.

When you build an application using PhoneGap, you are essentially building a mobile web site using HTML5 and JavaScript, just like you would build any other web site today, but you are putting the HTML and JavaScript on the phone.

PhoneGap applications run on the local browser on the phone and have some hooks into the native libraries which are exposed to you through their JavaScript APIs.

What does all this mean?

Well, it means that if you are developing a PhoneGap application, you can develop it just like a cross platform mobile web site.  You can use any mobile framework you like, for example Sencha Touch, or JQuery Mobile, etc.

You will for the most part be able to share just about all of your code since your application will be HTML and JavaScript, but you will not be writing a native application.

Because your PhoneGap application will be running in a browser it will be more like a web application than a native application.  The user interface you design will not use the native controls and will be subject to the limits and speed of a web browser.

This also means that you might have to write some platform specific code to make up for differences between the browsers, but you can basically assume that you will be able to share most of the code.

The tooling for PhoneGap depends entirely on the environment you want to build the app with.  You can develop in whatever environment you would like and basically use a plugin for the IDE in most cases.  There are quite a few manual steps, so getting setup is not that easy.

One big benefit to PhoneGap though is PhoneGap build, which allows you to upload your project in whatever environment you created it in, but build it automatically for the other platforms.

Books:

Appcelerator Titanium

I want to mention this platform next because many developers confuse this with PhoneGap.

2013 06 28 12 52 58 thumb Which Cross Platform Mobile Development Platform Should You Choose?

Appcelerator Titanium is completely different than PhoneGap.  The only similarity is the language that is used is JavaScript.  Everything else is completely different.

With Appcelerator Titanium you use a cross platform mobile development custom API to build your application.  This is different than PhoneGap or Xamarin, because with Xamarin you use a wrapper around the real native SDKs and with PhoneGap you use whatever you want to build an HTML5 web application.

With Titanium you actually write all your code against their SDK which includes UI components as well.  So this means that when you write a Titanium application you actually can write a cross platform user interface.

Appcelerator Titanium apps are actually compiled down to completely native applications that use the real native controls for the platform.

For example, in Titanium you can programmatically declare a button and specify its layout and some attributes about that button.  When you compile your application, the button will appear as a real native Android button on Android and a real native iOS button on iOS.

Does this mean that you can build a completely cross platform application including the UI with 100% code reuse and do it in JavaScript?

Maybe, but highly unlikely.  Many of the UI elements and interaction paradigms are cross platform, but parts are not.  For example, in iOS you have the idea of a Navigation Controller which keeps track of the history of what screens you navigated through and lets you go back; Android doesn’t have such a control.  But, Titanium does have support for platform specific controls, it just means that you have to make some of your code conditional based on the platform.

All this is to say that you can program to the lowest common denominator and get a fully cross platform application with close to 100% code reuse, but even though you’ll have native control, the result might not look that great.

The reality is, if you are using Titanium, you’ll probably want to tailor some parts of the application to the specific platforms.

Titanium actually has some really good tooling.  There is a Titanium IDE which is actually pretty nice and does a really decent job of auto-completing JavaScript code, especially in regards to the Titanium APIs.  The build process from the IDE is pretty simple and even lets you build a web application out of the same codebase.  There is also a marketplace that has components you can use and purchase for your applications.

Titanium recently introduced an MVC framework called Alloy, which greatly simplifies creating Titanium applications and takes out the tedium of programmatically creating all the user interfaces.  With this framework, you declare your user interface using an XML markup, which is pretty straight forward.  You then use controller classes to populate and interact with the UI.  It also has the concept of style sheets which are very similar to CSS.

One of the most impressive things about Titanium though, is its cloud offering.  Titanium basically lets you have access to their complete backend of cloud services which allow you to easily create what can be best described as Facebook-like functionality without having to code your own backend.  You can use the cloud services to manage users, authenticate them, store data about the users, like social graphs and even just store key value pairs.  I was really impressed by this functionality.

Books:

Appcelerator Titanium Application Development by Example Beginner’s Guide (Darren Cope)

Appcelerator Titanium: Patterns and Best Practice (Boydlee Pollentine, Trevor Ward)

More cross platform mobile development options?

There are obviously many more options out there, but I picked these three for standard application development because from my experience these are the most serious widely used offerings.

These 3 offerings also encompass just about all the ways to do cross platform mobile development:

  • Shared code, but separate and native UI (Xamarin)
  • HTML5 App running locally (PhoneGap)
  • Fully shared code native app (Titanium)

There are obviously trade-offs to each of these approaches and nothing is quite perfect, but I do consider all of these good solutions at this point.

In general, I prefer the Xamarin approach because I like having control over the native user interface completely and I like being able to develop in C#.

If I were to develop in PhoneGap today though, I’d most likely use Icenium, which is basically an IDE and set of build and testing tools built around Cordova (the open source part of PhoneGap,) that makes it much easier to develop in and deploy.

Don’t forget to check out my Pluralsight courses if you want to learn how to get up and running quickly with some of these mobile development frameworks.

  • Rémi BOURGAREL

    If your’e using Phone gap you should checkout durandaljs which is a mvvm framework for single page app (using knockoutjs, requirejs, and jquery)

  • Andy Dent

    Hi John

    What about using C++ as your core language, for someone who already has strong C++ skills? It is also available in Windows Phone 8 and is natively supported by all the phone vendors, as opposed to having to go through Xamarin. (Nothing against them – awesome product!)

    The main difference I think is a productivity thing not so much for the language as the core .Net APIs available in Xamarin’s MonoTouch and MonoDroid. So it makes sense for people to look at their app functionality and see what frameworks they may need.

    For 2D games, Cocos2D-X has had a lot of backing from China Unicom and is now on all platforms. It has a lot of similarity to the new SpriteKit in iOS 7.

    • jsonmez

      Hi Andy,

      The only problem with using C++, is that you don’t have access to the same level of abstractions as you do with the other choices.
      So, if you wanted to create a cross platform app using C++, I believe you would have to invent your own abstraction layer to make a common interface between all of the platforms. Not sure if anyone already has something like that, but there isn’t anything I know of.

      But as for games, you are right, there you can certainly use C++ and have a consistent API to program against (for the most part.) There are quite a few options in that realm.

      I have found MonoGame to be a great cross platform choice for mobile game development though, LIbGDX can also be used for Java and of course there are things like Unity and Corona which are also nice and cross platform.

      • Andy Dent

        Hi John

        My impression was that Monotouch and Monodroid only abstracted things like network and filesystem and for any UI work including event handling, animation or image-processing you had to write platform-specific code.

        So I’m not sure how much abstraction is missing by comparison with C++.

        One cool thing I spotted in my brief re-look at Monotouch that this sparked – they now support F# so you can write functional plugins with F# for iOS and Android.

        • jsonmez

          MonoTouch and MonoDroid are using the native SDKs, just wrapping them, so you have those layers of abstraction.
          My understanding in developing with C++ on these platforms is that you would have to operate at a lower level.
          So, for example on Android, the Android libraries that we use to build Android apps are Java libraries, take the Activity class for instance.
          If you use C++, you won’t have access to that, (at least as far as I know, but I have to admit I have not tried to develop a C++ app for Android.)

          • Andy Dent

            Native Activities have been around for a while, there’s a really good series I clipped http://www.altdevblogaday.com/2012/02/28/running-native-code-on-android-part-2/

            I’m sure the C# layer in MonoXX is much easier to use than C++ for this stuff, still. My point was that the applications are still being coded differently for each platform with significant UI and event-handling logic. It is only very core gameplay or business logic manipulating data that can be common. As I recall, that data manipulation includes LINQ so if you’re a fan of LINQ that’s another reason to go mono.

    • Icaro Bombonato

      +1 for a course on Cocos2d-x with Visual Studio and C++.

      Cheers!

  • Pingback: Which Cross Platform Mobile Development Platfor...()

  • Shai Almog

    Why didn’t you mention Codename One? (disclaimer: I’m one of the developers).
    Its pretty different from everyone else you mentioned and far more complete than most.

    • jsonmez

      I wasn’t aware of it. Checking it out now. Looks great!

  • Andy Dent

    Another one that’s very interesting is Marmalade http://www.madewithmarmalade.com/marmaladesdk/features/ui-frameworks which has its own patented abstraction layer allowing programming in C/C++, hybrid with calls to C++ or Lua. I have been following them with minor interest for a year or so. Recently they have been aggressively marketing in the Blackberry and Windows Phone 8 space. I’m sure there are compromises somewhere but they claim a much more seamless cross-platform experience than Monotouch because they include UI abstractions, made available via rendering on other platforms and using native controls on iOS and Android.

    • jsonmez

      Nice! I wasn’t aware of that. Thanks for pointing that out.

    • Juraj Eldo

      This is only for Windows or OS X not support Linux , bad bad bad….

  • Scott

    When developing an iOS app using Xamarin, is a Mac necessary then for compiling the app?

    • jsonmez

      Yes, you do need a Mac to compile.

  • Sophina

    I would like to add IBM Worklight too for cross platform,hybrid, and native mobile app development. It offers more features over PhoneGap: http://mobileappstuff.blogspot.com/2013/06/how-ibm-worklight-is-different-as.html

    • jsonmez

      I hadn’t seen that one yet. Will check it out. Thanks for posting.

  • Pingback: Which Cross Platform Mobile Development Platfor...()

  • hal9k2

    Hello, nice comparison, is xamarin free for android or you have to buy components?

    • jsonmez

      There is a free version limited by the size of the app.

  • Marc Greiner

    DevExpress offers an HTML5 JavaScript framework for smartphones and tablets, called PhoneJS.
    This framework contains everything you’ll need to create native client applications using HTML5 and JavaScript with a single codebase and deliver solutions that target today’s most popular smartphones and tablet devices.

    Keywords: touch-optimized user experience, natively rendered widgets, straightforward page navigation, view management, data access layers, single page application, iOS, Android, WindowsPhone, ready for online publication or packaged as a store-ready native app, Apache Cordova (PhoneGap), jQuery, Knockout.

  • jayesh

    i am usign Appcelerator titanium since 1.5 years it’s just amazing

  • pythonflash

    Thanks for the excellent perspective on cross mobile.

    Question: If you’re at the hobbyist level, and financially don’t wish to update Xamarin at the $299 every year, do you think you can get away with updating only, Every Other year, as long as you’re not using the most innovative new additions to the WP8 and the iOS sdk additions, and thus not require the Xamarin updates every year ?

    • jsonmez

      Yes, I would say you could. But it is hard to say what the future will hold.

  • Owen

    Thanks for the nice post. I have been trying to get this tips on Google but finally found here.

  • Bry

    Have you ever try CrossLight? Its partner with Xamarin. You can reuse the code for iOS, Android, WP.

    • jsonmez

      Yes, that is a nice project that is coming along well.

  • Ignacio Rosario

    What about rhomobile? as a person with rails and ruby knowledge, wouldn’t you recommend it for me? or should I just take one of the javascript based as I also have a strong web development background? which option is better?

    • jsonmez

      I have tried out rhomobile, and I wasn’t a big fan. I didn’t see any real advantage of it over the JavaScript based ones.

  • Vance Feld

    What about OpenFL? Compile to c++ using FL api as a base language.

  • http://www.vusisindane.com/ Vusi Sindane

    Hey, what do you think of flashbuilder? I know it’s paid, but is it worth it?

    • jsonmez

      I haven’t used it enough to have a good opinion.

  • GonZaloo Higuaín

    Thanks for this topic but i have a question, is facebook app instagram twitter and soundcloud made by this ways or they made using eclipse and xcode?

    • jsonmez

      Good question. I don’t know the answer. I will try and find out.

  • Usama Ahmed

    You totally forgot Adobe AIR or else you don’t know about it.

    • jsonmez

      There are quite a few I left off, but I didn’t consider AIR to be used enough for cross platform mobile development to be listed here. I could be wrong, but I haven’t seen much done with AIR for iOS and Android.

      • Bozzified

        A ton of applications are built with AIR alongside some of the Adobe stuff as well.. native extensions are also a huge power for AIR as you can include native libraries to do specific things on top of the AS3 code.

        Not to mention that aside from Xamarin, AIR will be far smoother and faster application running on Android and IOS when compared to PhoneGap and Appcelerator. HTML5 is terrible for mobile development. End of.

        I would recommend EVERYONE to avoid it as much as possible. Xamarin/AIR/native dev are really the only things you want to use to build native apps.

        PhoneGap and Appcelerator are great for simple simple apps that do one thing and don’t require a lot of visual elements and transitions. Even with CSS3 and hardware acceleration of css it’s not really ideal because hardware acceleration on iOS, Android and Windows Phone are all different performance and smoothness and really drop in performance as you have a lot of visual elements in the UI. This doesn’t happen with other frameworks including AIR. AIR for example is fully GPU accelerated even if you use traditional display list with AS3.

  • http://www.mobilepundits.com Mobilepundits

    I always prefer PhoneGap for my cross platform mobile apps, Its easy , effective and great way to develop platform independent mobile apps.
    Sencha touch is also a great option for touch enabled mobile apps.

  • Anand Joshi

    Thanks for the nice post. Have you ever try Primefaces Mobile?

    • jsonmez

      I haven’t, I’ll have a look.

  • http://www.mobilepundits.com/Cross_Platform_Mobile_Development.html Astoria Johnson

    Well i choose Phone-Gap cross platform tool because its API’s allow me to access the new capabilities of device.

  • Inga Kletsova

    Are you only looking into code-based app building platforms? What about those ones that do not require any coding at all? Like Snappii or something…

    • jsonmez

      Yes. I was just considering coding based ones.

  • http://www.tanzaniteinfotech.com/ tanzanite infotech

    I found Adobe AIR (Adobe Integrated Runtime) the best way for Cross Platform Mobile Development. But there are number of another interesting solutions. I’ll do the development with other solutions also. Thanks Jsonmez for very interesting and knowledgeable post, I have learned a lots from this post.

  • Pingback: Bạn nên chọn công cụ nào để phát triển ứng dụng di động đa nền tảng? | VinaCode()

  • Hung Nguyen

    Really good explanation, thank you so much !

  • Marouane

    how much can cost developong with Xamarin ?