Guest post from Eun-Kyung Choi – Ed.
Why BlackBerry?
Over the past months, we’ve been showing you what the new BlackBerry 10 platform is all about and how easy it is to create rich and astonishing-looking apps for BlackBerry 10 using the Cascades UI framework. Not only does BlackBerry 10 offer an awesome platform and an extensive set of tools to choose from, but BlackBerry World is the most profitable mobile application store for app developers to submit their apps. According to the Evans Data Corporation, 13% of vendors using BlackBerry World are making over $100,000, which is more than Apple, Android and Windows Mobile. With BlackBerry 10, you have the option to integrate your application with BBM functionality, thus increasing the engagement and discoverability of your app. It is reported that BBM connected apps make up 20% of the app downloads from BlackBerry World. Also, the Built for BlackBerry Program and the $10K Developer Commitment programs are offering amazing incentives to bring your app to BlackBerry 10. I’d say that is a pretty convincing motivation to start developing apps on BlackBerry 10. So let’s get started!
Tips on Porting Native iOS apps to BlackBerry 10
Knowing that you’ve already developed and deployed profitable apps on the iOS platform, we would also like to see your great apps on BlackBerry 10 and watch you march toward another successful launch. To help you along, we have compiled several tips to help you through the porting process. We published a detailed porting guide for iOS apps on our Cascades microsite. The guide describes the similarities and differences between native iOS and BlackBerry 10 apps and platforms, as well as providing information and best practices for the porting process.
Tip 1: Know the Platforms and SDKs: iOS VS BlackBerry 10
Both the iOS and BlackBerry 10 platforms:
- Manage the device hardware and provide the technologies and services to develop native apps;
- Provide their own SDK to build, test and deploy native apps which can run directly on their devices;
- Communicate directly with underlying hardware through well-defined APIs;
- Are structured similarly in a layered manner, outlined in the image above. BlackBerry 10 is based on the QNX Neutrino RTOS. The QNX Neutrino RTOS acts as a kernel and gives the platform key functionality such as multi-tasking and memory management. Both platforms offer core services, graphics and audio accessibilities, application and UI development frameworks.
Because both platforms use this layered architecture, the way you use frameworks is similar between iOS and BlackBerry 10. As a best practice for both platforms, you want to use higher-level frameworks over lower-level frameworks in your app whenever possible. This helps to reduce the amount of code you have to write, and can simplify complex features. This applies when creating new apps, as well as porting existing apps. The important thing to note for the porting process is that in most cases, although the frameworks are different between iOS and BlackBerry 10, there are equivalent APIs that you can use to map iOS frameworks to BlackBerry 10. In our iOS porting guide, we provide more detailed mappings for commonly used classes and UI components between iOS and BlackBerry 10.
Tip 2: Know the Development Tools: Xcode VS QNX Momentics IDE
One of the challenges of bringing your app to a different platform is learning to use a new IDE. Xcode and the QNX Momentics IDE share a number of similar features such as creating projects, designing user interfaces, writing code, debugging and running applications on simulators or devices which should offer some familiarity for experienced iOS developers. Both tools come with a project explorer, a source editor, and a UI previewer/editor to organize and write the application code using static libraries and plug-ins. Both tools support the gcc compiler to compile C/C++, and it is possible to perform source level debugging using GDB.
Xcode has an integrated UI design tool called Interface Builder and uses Objective-C for creating the UI for apps.
The QNX Momentics IDE is an Eclipse based environment to develop native BlackBerry 10 applications. It comes with the built-in Cascades Builder for the UI development using C/C++ and QML. Understanding and familiarizing with the development tools will lead you to make better choices during the porting process.
Tip 3: Know the Development Language: Objective-C, C/C++ and QML
Native iOS apps are built using Objective-C language and frameworks while Native BlackBerry 10 apps can be developed using C/C++ and QML. Because Objective-C is a set of extensions to the standard ANSI C language, you can mix Objective-C with C/C++ code. This similarity between Objective C and C/C++ allows you to reuse the Objective-C code that you already have by wrapping to C++ using the PIMPL idiom. In the context of porting your app, wrapping allows you to use your existing Objective C libraries on BlackBerry 10.
QML is a JavaScript-based, declarative language for developing an application’s user interface. If you are not familiar with QML, don’t worry! Cascades gives you the flexibility to create your UI in both QML and C++. Here is how to integrate the two in detail. The following two code samples written in QML and C++ achieve the same result when the application is run.
Adding a label using QML
import bb.cascades 1.0 Page { content: Label { text: "Hello world" } }
Adding a label using C++
Page* root = new Page; Label* label = Label::create() .text("Hello world"); root->setContent(label); app->setScene(root);
Tip 4: Design your app targeting multiple platforms: Reuse! Reuse! Reuse!
It will save you a lot of time during the porting process if your native application is designed and developed targeting multiple platforms by separating UI code, business logic and platform dependent code. Follow the best practices to develop cross-platform applications:
- Separate business logic from UI code following the Model-View-Controller (MVC) pattern. BlackBerry 10 doesn’t enforce you to follow the MVC pattern. Although you can develop your app’s UI in both QML and C++, it is encouraged to write UI code in QML and business logic in C++ since the benefits of this practice are greater when porting apps.
- Use cross-platform libraries, frameworks, and engines to maximize the reuse of your app code. For example, consider using Open Audio Library (OpenAL) interface for audio and OpenGL ES for graphics. They are a cross-platform standard.
- Use SQLite for the app’s database engine. It is supported on both iOS and BlackBerry 10.
- Wrap your Objective-C code to C++ to reuse.
- Isolate platform dependent code and package them separately. You can replace or rewrite the platform specific code by mapping the equivalent or similar classes and functions.
There isn’t an easy way to reuse your UI code and platform specific code. After all, iOS and BlackBerry 10 are two different platforms. You would have to spend some time researching and finding similar classes, UI elements, and/or equivalent components between iOS and BlackBerry 10 for porting. The good news is that we put significant amount of resources to guide you through the process. The porting guides, webcasts, blogs and forums are one click away on our BlackBerry Developer’s Website.
Tip 5: Quality, not Quantity: Follow BlackBerry 10 UI guidelines and best practices
Follow the BlackBerry 10 UI guidelines and design principles to create the best experience possible for your users and take advantage of the unique BlackBerry 10 features. BlackBerry 10 eliminates gaps between action and response, makes the experience smooth and effortless avoiding any interruption in the flow, and creates an experience where content is maximized in your app. Aim for 60 frames per second (FPS) so that the UI and the screen refresh rate are in sync.
There you have it. Port responsibly!
For more information about porting iOS apps to BlackBerry 10, please refer to the following:
BlackBerry 10 Best Practices
Porting native iOS apps
Porting apps from iOS
BlackBerry 10 Library Support at a glance