Lessons learned on Apache Cordova

It took me 2 weeks from initial inception to AppStore submission, which I believe is a very short timeframe considering this is my very first attempt and I had to start from scratch: from downloading and installing the OS and dev tools to learn each and every bit of the technology I picked.

By the way, did I mention I used Apache Cordova (v 2.7.0), previously known as PhoneGap?

Well, Apache Cordova itself greatly ease the task for people like me having some web development knowledge because all you have to do is HTML5 development. You don’t even need to have the classical development tools (XCode and stuff) to start programming your app.

I decided to use jQuery Mobile (v 1.3.1) for the UI, and after a couple of trials I was able to turn my mockups into real screens in a matter of minutes. Piece by piece the UI was practically shaped in less than a day, I only had to wire the logic behind it to make it of any use.

I had some previous experience with jQuery and event based programming is not something foreign, I just had to adapt to the new events and the jQuery Mobile DOM enhancement model, but that wasn’t really though. A little bit of trouble was caused when I started using HTML5 WebSQL: I thought there was a better standardization on that side than I found, but an opensource library called PersistenceJS eased the task again.

Everything looked great, even when I started testing my app on the device by serving it from a Tomcat instance and opening it into Safari Mobile on my iPhone: it looked just a little bit slower, but still responsive enough.

Next step was wrapping the app within the Apache Cordova framework and here I spent most of my time: not because it is something complex, just because it was something completely foreign to me. Luckily the online guides are well written and easy to follow even to someone that has no experience at all with OSX, XCode and iOS development.

The real disappointment came once I managed to have the Cordova integration completed and my app deployed on my iPhone 4S after paying the $99 yearly fee to Apple: the app runs very slow, unacceptably slow considering what it does.

I looked around, googled in the desperate search of something I missed, an optimization step or a library update, only to discover there’s nothing I can do to speed it up: the WebUI component the iOS SDK provides to iOS developers, the component Cordova uses to render your HTML5 app, is inherently slower than Safari Mobile. Even in the latest iOS versions and apparently the reason behind this slowness is security and the JavaScript engine used: Safari Mobile uses something called Nitro which is not available to the WebUI component.

Nonetheless I decided to go ahead: I wanted my app published on the AppStore and complete my task.

Here came my second disappointment: Apache Cordova plugins, those little bits of code that allows Cordova developers to integrate native features not included into the core SDK, are a big mess, probably due to the recent migration of the project under the Apache Foundation umbrella.

The PhoneGap to Cordova migration has caused some core framework changes, like the rename of the main JavaScript class that has been changed from PhoneGap to cordova. These changes, even if small and trivial, can cause a lot of troubles to newcomers like me: silent failures and unexplicable behaviours to start with.

I need three plugins only: local notifications to create alarms, AdMob integration for advertisement and Google Analytics for… guess what! Well, none of those plugins worked straight away in the version I downloaded.

I might have downloaded the wrong versions from the wrong repository, I admit my lack of knowledge, but what I did for each one of those is run a Google search and pick the results from top to bottom until I got something looking promising: the usual process.

After many trials, many errors and many swears I managed to get enough knowledge on Cordova, XCode and Objective-C to fix/update the plugins myself: I will share my fixes on GitHub as soon as I manage to fork the right project because there are so many forks out there that’s not even easy to identify the correct one.

The end of the story is Apache Cordova is a fantastic framework to develop mobile apps, the native OSes though do not provide performing components to empower Cordova and the moltitude of plugins need some sort of coordination and management to bring some order and clarity.

Next step: give a try to the Titanium Platform which implements a different philosophy but still uses JavaScript (no HTML5) as programming language.

Advertisements

2 thoughts on “Lessons learned on Apache Cordova

  1. “… After many trials, many errors and many swears”…. uhmmm…. for swears you mean aiachristensen&mortenolsen! with various holy columns, right? 😉

    Like

  2. Pingback: Cordova: loves and hates – nickneptune

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s