The Wayback Machine - https://web.archive.org/web/20120430163921/http://www.straightforward.se:80/storyserver/html5-javascript-css-c-and-cpp-mobile-apps-using-the-mosync-mobile-sdk

Creating HTML5 and C/C++ hybrid mobile apps with the MoSync Mobile SDK

Tagged:  

I do a lot of work with the MoSync team. The team is creating a mobile app SDK with some great features. It's an open-source effort, and there are people in Stockholm and Lund in Sweden, in London, and in Cluj in Romania, all putting together a fully-featured software development kit based around pre-written libraries in JavaScript, and under the hood, C/C++.

 

The MoSync SDK outputs application packages, ready to install, for many of the major mobile platforms, like Android and JavaME, and can output iOS and Windows Phone projects which can easily be finalized in Xcode and Visual Studio.

 

It's open source -- yes, it's free! -- and it's a fully featured cross-platform mobile app development kit.

 

Although the latest development effort by the team is in the area of HTML5 and a new rapid JavaScript development tool called Reload, the unique thing about the MoSync SDK is its wonderful C/C++ layers. The SDK includes many, many pre-written low-level C functions (the MoSync team call them "syscalls") that you can use if you want to dive down deep into the functionality of the devices (mobile phones, pads, and other clients running Android, iOS, Windows Phone, Java, etc.) the kit supports.

 

You can use syscalls to talk to the phone's sensors for example — call the accelerometer and track movement, query the magnetometer to get a reading on north, measure rotation with the gyroscope, and so on. Syscalls also let you get in contact with other location-based features, like GPS, and use close-proximity communications features like NFC and Bluetooth.

 

There are literally hundreds of these C syscalls (and IOCtl’s) which pretty much allow you to do anything that the device operating system will let you. The MoSync team have made a good fist of implementing these low-level functions on all the major mobile platforms, although inevitably there are few holes — mainly where the platform itself is the culprit, thanks to buggy or inadequate code from the vendors.

 

The MoSync SDK's syscall library continues to grow with each release and it is getting harder these days to find some device feature or capability that the team hasn't implemented, at least experimentally. There is an excellent survey at the MoSync site which shows which syscall is supported where.

 

MoSync Eclipse IDEMoSync Eclipse IDEThere is no need to go down into the C syscall layer at all. The MoSync team have created whole libraries of C++ classes that amalgamate the syscall functions into sensible objects you can create, use, and destroy in runtime. In this layer of a MoSync app you can work with things like maps — showing, for example, your current location as a satellite image.

 

There are also social media libraries for Facebook and Twitter integration, and classes for handling banner ads, notifications, downloads, XML files, and so on. There is a lot of stuff available to experienced C/C++ programmers and even for experienced ones. Plus there are great tutorials and coding guides at the main MoSync website.

 

In release 3, the SDK has improved support for HTML5. In fact it is now possible to create a complete mobile app using nothing more than HTML5, JavaScript, and CSS. Just as it’s not necessary to dig down into the C layer, you don't even need to look at the C++ layer. Your HTML pages contain your mark-up, embedding JavaScript wherever you need it. You can use JavaScript for buttons and input/output fields and other user interface elements.

 

Your JavaScript files, web pages, and other HTML5 resources like images and media files all sit in the same folder in your project and get bundled together at build time and end up in the multiple packages that the SDK outputs.

 

Typical MoSync app, using Native UITypical MoSync app, using Native UIThere is a new "Wormhole" library, which contains JavaScript functions for handling native user interface widgets, so you can get the look and feel of a native Android, iOS, or Windows Mobile app. The Wormhole library is also packed with a lot of PhoneGap-compatible functions, with the intention being that it should be quite simple to port existing PhoneGap apps to the MoSync SDK. And on top of that, the Wormhole library  makes it possible for the JavaScript functions in the HTML5 layer of your app to talk to the code (either your own or the pre-written code written by the MoSync team) in the C/C++ layers.

 

The development of the MoSync SDK can seem a little higgledy-piggledy, as new bits grow and some other bits get left behind and you are not completely sure what's new and experimental, and what's old and no longer gets active support, but there is a strong feeling of excitement in the team — which has been going for seven years now — and there is a very active developer community that bends over backwards to help with problems and suggest solutions.

 

Each new release brings a whole range of interesting goodies for the serious mobile app programmer to play with. The SDK is full of unexplored little gems like the NFC API. It’s a heck of a lot of fun to work with, and to help develop, and to make mobile apps in!

Post new comment