Developing mobile applications for Android, iOS, etc, has become the coolest activity in the cyber world. There are a lot of software development kits SDKs available in the market for developing mobile applications but it has always been tough to select the ideal SDK from among the different ones available. For a mobile app developer who is always on the lookout for the best technology to build an application as fast as possible, free and open source software comes to the rescue. MoSync is an SDK with which you can develop applications for different mobile platforms from a single code base.
MoSync is a free and open source cross-platform SDK for developing mobile applications using C, C++ or both in combination with HTML5 and JavaScript. MoSync allows you to develop applications for a wide variety of mobile operating systems. It is now available only for Windows and Mac OS X, and enables the development of native mobile applications for up to nine different platforms at once. It can be used by any beginner, with knowledge of C or C++, to develop mobile applications.
Developed by a Swedish company named MoSync AB, MoSync is incorporated with the Eclipse development environment and is offered under a dual licence scheme a commercial licence and the GPL open source licence. Under the terms of the commercial licence, the user needs to subscribe to the software, whereas under the GPLv2, the developer can sell the applications developed. After introducing MoSync, the developers included additional features and enabled support for HTML5 and various mobile platforms.
MoSync supports iOS, Android (2.x 4.x), Windows Phone, Symbian S60, Java and the Mobile Linux platforms.
MoSync is a good choice for app developers because of the following reasons:
- Applications can be developed using C, C++ or HTML5.
- Since it is open source software, it has been under active development since 2004.
- Wormhole technology offers developers the Web view function.
- It is based on an Eclipse development environment.
- Wormhole technology allows HTML5 to access the underlying C/C++ layer.
- HTML5 can access the hardware using C system calls. This makes it easier for the GUI and application logic to be written in HTML5.
- It has built-in emulators to check the functionality of native applications in the respective platforms.
- It enables porting of existing applications to various mobile platforms.
- Wormhole JavaScript library provides access to device functionality like sensors, cameras, networking, file systems and so on.
Installing MoSync
MoSync is available for Windows and Mac OSX. It can be downloaded from http://www.mosync.com/download
The system requirements for Windows are:
- Windows XP, Windows Vista, 7 or higher
- 300MB free disk space
- Java SE Runtime Environment
And the requirements for Mac OS X are:
- Mac OS X Snow Leopard (10.6.6 or higher)
- 250MB free disk space
- Java SE Runtime Environment
- Xcode
Xcode can be installed from the Apple App Store. It is required to build device-ready application packages for iOS.
A comparison of MoSync Reload and the SDK
MoSync Reload is a tool to develop applications in HTML5 and JavaScript for Android, iOS and Windows Phone mobile platforms, and instantly see the results on any number of devices or emulators. It enables you to quickly edit HTML/JS/CSS code and run itjust like pressing the reload button in a Web browser. Native features such as sensors, cameras, etc, can be accessed and the user interface can be created using real native UI components. Available for Linux, apart from Windows and Mac OS, MoSync Reload can be downloaded from http://www.mosync.com/download/reload
Developing your first C/C++ application
All it takes to build your first application is a beginners knowledge in C or C++. Lets go through a very simple C/C++ program, which will familiarise you with the fundamentals of the MoSync API and event handling.
Launching MoSync: Install MoSync and launch the application by right clicking the MoSync IDE icon.
Creating a new project: Next, follow the steps given below to create a new project:
- Select the default workspace folder.
- Create a new project by clicking the File tab and navigating to a new project.
- Select MoSync Project from the C/C++ wizard.
- Select the C++ Moblet Project template from the template section.
- Conclude the creation of the new project by entering a name for the project and clicking on the Finish button.
Coding: Now, type the following commands:
#include <conprint.h> /* Developing your first C/C++ Application. * Author: Vishnu NK * Open Source For You * */ using namespace MAUtil; class MyMoblet : public Moblet { public: MyMoblet() { maSetColor(0xFFFF00); //To set color for the text maDrawText(125,220, MoSync); maSetColor(0x00CCFF); maDrawText(80, 240, Open Source For You); maSetColor(0x33FFFF); maDrawText(100,450, By Vishnu Nk); maUpdateScreen(); } /*Called when a key is pressed. */ void keyPressEvent(int keyCode, int nativeCode) { if ( MAK_O == keyCode || MAK_BACK == keyCode) { //Function to close the application. close(); } //Displays the key pressed. printf(You typed: %c\n, keyCode); } /** * Called when a key is released. */ void keyReleaseEvent(int keyCode, int nativeCode) { } }; /* The main function of a program. */ extern C int MAMain() { MyMoblet myMoblet; Moblet::run(&myMoblet); return 0; }
Running the application: After finishing with the coding section, its time to build and run your application.
- Click on the projects name in the Project Explorer view so that it is highlighted.
- Now, either press Ctrl+F11 or the Run button on the toolbar to build and run your application.
- The MoRE emulator, the default emulator for MoSync SDK, can be chosen when prompted.
Table 2 compares MoSync with other SDKs.
Updates
Whats new in MoSync SDK 3.3
- C++ camera API: The new version comes with a C++ camera API, which enables the applications to make use of the devices camera.
- MoGraph: MoGraph 3D Library can be used to create animated diagrams, 3D charts, display real-time data, visualise data and create artistic applications and animations.
- Screen transitions: The release has added native user interface screen transitions to give the right look and feel.
- Custom Picker widget: This enables you to implement a drop-down list with custom elements.
Whats new in MoSync Reload 1.1
- Command line tool for Reload: The command line tool can be used to control the Reload server, integrate Reload with existing development tools and create scripts to perform Reload tasks.
- Updated Reload client, development UI and Reload server: An updated Reload client includes automatic server discovery, support for saving projects locally, etc. The new development UI has also enabled a lot of new features including a new workbench and a highlight hint help system.
MoSync SDK 3.2 announces on-device JavaScript debugging
The MoSync SDK 3.2 release comes with a JavaScript debugger, extended libraries and APIs supporting the Android 4.x platform. The new debugger ensures the robustness of the code. The existing code can be also used to develop applications for the Android 4.x platform, which ensures conformity with the most used Android version.
References
[1] http://www.mosync.com/
[2] http://www.mosync.com/docs/reload/index.html
[3] http://www.mosync.com/docs/sdk/index.html
[4] http://www.mosync.com/docs/sdk/cpp/examples/index.html