Multiple targets

by Tim Anderson

If your app needs to run on Windows, Mac, Android and iOS, which tool should you choose? Tim Anderson looks at the options.

HardCopy Issue: 64 | Published: October 30, 2014

The development landscape has never been more diverse. Important client platforms today include Windows, Mac, iOS, Android and web browsers, while other mobile platforms such as Windows Phone and Blackberry are also significant. Such diversity has stimulated interest in cross-platform development tools as businesses try to reach the broadest possible market. But is it possible to go cross-platform without compromising the user experience on each device? And for those who do go the cross-platform route, what are the pros and cons of the available tools?

There will always be compromise in a cross-platform project. If you have the luxury of developing for a single operating system then you can use the native SDK, get the best possible performance, and fully integrate with the features of the chosen OS and device. That said, the quality of cross-platform tools has improved to the point where excellent performance and interface integration becomes possible, given some effort. If you dismissed cross-platform mobile development a few years back, then it is time to take another look.

It is not usually possible to share 100 per cent of the code. All the tools described here allow conditional code that targets specific platforms, as well as native extensions that give access to unique features or optimise performance bottlenecks. The amount of code you can share depends partly on the approach you take, and partly on the requirements of the specific application.

What about Google’s Chromebook? This is a tightly locked-down platform which is essentially a Chrome browser with some offline capability. It is popular in education thanks to its low price and easy management. However applications for Chromebook are web applications; if you have developed a web application it will work on Chromebook, though you may want to add offline features such as local storage.


Cross-platform approaches

The native SDK for Windows is largely C/C++, with .NET a widely used framework that wraps the API for languages including C#, Visual Basic and F#. Apple’s OS X and iOS use Objective C, an object-oriented version of C which is quite unlike C++. Android’s native SDK uses Java, with an option for C/C++ using the Android NDK, although Google does state that “the NDK will not benefit most apps”. Windows Phone 7 uses Silverlight, while Windows Phone 8 adds an option for Windows Phone Store apps that use either .NET or C/C++.

How can you wrest these diverse SDKs into one language and tool that targets them all? There are two common approaches.

The first is to write a web application and wrap it with native code, so that from the user’s perspective it works like an app with no need to open the web browser. All platforms provide a way to embed the browser engine, and this approach also allows you to share code with a conventional web application. You code the application in JavaScript, HTML and CSS.

Today’s JavaScript engines are fast, using just-in-time compilation for high performance, making this an excellent choice for apps that work cross-platform, and for which most of the code is shared. If you need to call a native API, for example to get access to device-specific features or sensors, you can do so through the native code wrapper.

Google is a web-oriented company, so as you would expect, the Chrome browser on Android is excellent, and is more widely used than the stock Android browser. Apple’s mobile Safari was some way behind, but the mobile browser in the recently released iOS8 is both faster and more capable. Tests carried out by Sencha show dramatic speed increases in some areas, and important new features including WebGL, IndexedDB (a database engine for web apps), JavaScript Promises, and CSS Shapes. In addition, there is a new embedded browser control called WKWebView, replacing the old UIWebView, which supports the Nitro JS engine, with four times the performance.

The main issue with the web engine approach is that web pages have a different look and feel from native applications. Everyone is familiar with the web, but in the context of an application a web-based user interface is unexpected. That said, the styling possibilities in a modern browser are so extensive that developers can mimic a native look and feel.

Frameworks that take this approach include PhoneGap/Cordova and Sencha Touch.


A CordovaApp in Visual Studio can target Android, iOS, Windows Phone and Windows Store.

The other approach is cross-platform compilation. One thing that all the major platforms have in common (including Windows Phone since version 8.0) is support for native executables. This makes it possible to cross-compile from a single source, creating native binaries for each platform. A further twist is that you can compile a runtime into an application and have that runtime execute your code, which may be in a language not normally supported by that platform.

Native binaries give the best performance and also make it possible to use every feature on each device, though you still need conditional code if you want to go beyond the subset of features that every platform has in common. Tools that bundle a runtime into the binary, such as Xamarin and Adobe AIR, give larger app sizes, though this is not usually a big problem thanks to smart optimisation.

The main issue with cross-platform compilation is what to do about the user interface. There are several problems. One is that controls such as buttons, menus and lists look and sometimes behave differently on each platform. Some tools overcome this by using custom-drawn controls, with conditional code in their libraries so that the correct control is drawn on each platform. Getting this completely correct is hard, especially when the platform vendor updates the operating system, so there may be things that are not quite right.

Another approach is to abstract the controls, so that a button component in the cross-platform tool calls the native API to render a button. This results in a more authentic native application, but with the challenge of abstracting the controls successfully so that developers can use all the features without unexpected behaviour.

Game development

If you’re developing action games then graphics capability and performance come to the fore, while use of native controls tends to be a non-issue; gamers just want an immersive experience and do not mind if each game has a unique appearance. Casual or puzzle games are less demanding, and can be built with any of the tools described here.

Unity is a popular tool for cross-platform game development, with broad platform support. The Unity engine is written in native code, but games are scripted in either C# or a version of JavaScript called UnityScript. The development environment runs on Windows or Mac.

WebGL is an API for rendering 3D graphics on an HTML5 canvas element. It is based on a subset of OpenGL, an API for accelerated 2D and 3D graphics. WebGL offers the prospect of cross-platform mobile game development using the browser engine, but support is limited. On Apple’s platform you need iOS 8. Google Chrome supports WebGL on Android, but the stock Android browser does not. Mobile Internet Explorer supports WebGL in Windows Phone 8.1.

A third solution is not to attempt a cross-platform user interface at all. You can write non-visual code in a cross-platform tool, but create a different user interface for each platform. Until recently, this was the official approach taken by Xamarin, for example. The snag is that less code can be shared, which means more development effort.

Key examples of the cross-compilation approach are Xamarin and Embarcadero RAD Studio, which includes Delphi.


Coding the back end

Most apps rely on back-end services to supply their data. Many apps are designed so that all the user’s data is synchronised to the cloud, letting users move between devices and get the same data and configuration on each one.

The good news is that common standards like REST and JSON (JavaScript Object Notation) make it relatively easy to access web services, while the major cloud services provide libraries for most platforms. If you use Amazon Web Services like S3, DynamoDB (NoSQL database) or SQS (message Queue Services), for example, then you can use official libraries for iOS, Android, JavaScript, .NET, PHP and more.

Despite the above, the extent and quality of support for specific platforms varies. If you are using Microsoft’s platform, for example, and want to integrate with Azure Mobile Services, Active Directory or a Web API ASP.NET project, then you will find more libraries and sample code for C# than for other platforms, even though Microsoft publishes SDKs for iOS, Android, .NET, Java, PHP and more. Such a situation might point you towards Xamarin.

The best supported platforms tend to be the ones that are most popular. Use Apache Cordova, for example, and you will find great support, especially since it is essentially a web platform.


Choosing a cross-platform soluton. (click to enlarge)


Cordova and PhoneGap

PhoneGap was developed by a company called Nitobi, to enable mobile apps that wrap the browser runtime. Nitobi was acquired by Adobe, and now the core PhoneGap technology is an open source Apache project called Cordova, while PhoneGap itself remains an Adobe product. Aside from support, the added value from Adobe is a cloud build service, which avoids the considerable pain of managing multiple mobile SDKs on your developer machine.

Adobe has also announced PhoneGap Enterprise which will add features including business collaboration, simple app editing, and integration with Adobe Analytics and Adobe Target for use in optimisation and marketing. PhoneGap Enterprise is currently in closed preview.

Cordova is the most mature and popular approach to cross-platform mobile development. It offers a high level of code reuse, and code can be shared with browser-based web applications as well as mobile apps. Access to device-specific features becomes possible through plugins covering various capabilities such as accelerometer, calendar, camera, contacts, storage, media players and barcode scanning.

Cordova also benefits from the many JavaScript and CSS libraries available, including jQuery Mobile which adds a touch-friendly mobile GUI on top of the standard jQuery library, and Sencha Touch which is a sophisticated and business-oriented framework.

You can use any HTML or JavaScript development tool with Cordova. The Apache download is command-line only. Many developers use Eclipse, an open source IDE, while Intel has a free HTML5 IDE called XDK which supports Cordova.

Microsoft has recently added Cordova support to Visual Studio 2013, under the name Multi-Device Hybrid App. There is integrated support for Android, iOS, Windows Phone, and Windows Store apps. Visual Studio’s JavaScript and CSS editor support is strong, more so if you install the free Web Essentials add-on.


Intel INDE


Intel INDE offers high performance tools for Android and Windows.

Currently in beta, the goal of Intel INDE is to bring together Intel’s native compilers and tools with cross-platform development for Android and Windows.

INDE is a suite of tools, many of which are fully production-ready. The tools include Intel’s C++ compiler for Android, Threading Building Blocks for simplified concurrent coding, Graphics Performance Analyzer (GPA) tools, Frame Debugger for troubleshooting rendering issues on Android, and Intel HAXM (Hardware Accelerated Execution Manager) for high performance Android emulation. INDE also manages the configuration of your development environment, whether Eclipse, Android Studio or Visual Studio, and the downloading of the Android SDK and NDK. You can code in either Java or C++.

When you install INDE you do not get the complete installation, but rather a configuration tool that lets you select which INDE components you require, and which IDE you want to use.

INDE is part of Intel’s push for Android, and although ARM is a supported target, it makes better sense for high performance apps that target Intel devices.


Embarcadero RAD Studio XE7

RAD Studio is Embarcadero’s development tool suite based around Delphi and C++Builder: two rapid application tools that let you write code in Object Pascal or C/C++ respectively. Key features of the suite include two-way visual development, so you can use visual and non-visual components either with drag and drop or in code, and native code compilation for fast binaries with few dependencies. The suite also includes an HTML5 development environment called HTML5 Builder.

Embarcadero’s recent efforts have been focused on cross-platform support for Mac, iOS and Android. The IDE runs only on Windows, but a typical set-up is that you install on a virtual machine on a Mac, using agents on the OS X side to compile and build for Mac and iOS.

Cross-platform projects use the FireMonkey GUI framework, which is incompatible with the VCL (Visual Component Library) for Windows but shares the same language and runtime library.

The latest release adds a multi-device designer for maximising shared GUI code, while still allowing platform-specific changes. There is also a feature for connecting apps locally over Ethernet or Bluetooth, called App Tethering, and new server middleware called Enterprise Mobility Services.

RAD Studio is an obvious choice for existing Delphi and C++Builder developers, and also strong if you have desktop as well as mobile targets in mind. It does not support Windows Phone. Despite its capability, it is a niche tool which means that finding libraries to support your favoured web services may be more difficult, though you can be sure it will be possible given sufficient effort.



Xamarin is a cross-platform mobile development company and tool which has its origins in the Mono project, an open source implementation of Microsoft .NET and C#. Company co-founder Miguel de Icaza was the creator of Mono. Xamarin came up with compilers for iOS and Android, and found immediate success among Microsoft platform developers who wanted to port C# code for mobile apps, or to create new mobile apps using a familiar language.


Using Microsoft Visual Studio to code an iOS app with Xamarin.

Xamarin’s approach is to focus on non-visual code for cross-platform support. This ensures a native experience and optimised GUI on iOS and Android. That said, the latest version, Xamarin 3.0, introduces Xamarin Forms, which lets you define a GUI layout in XML using a version of Microsoft’s XAML. The controls are rendered by the native operating system, rather than being custom drawn.

Although Xamarin does not support Windows or Windows Phone directly, it does support Microsoft’s Portable Class Libraries, so you can write code that runs on Windows platforms as well as on Xamarin. The IDE for Xamarin is either Visual Studio, or Xamarin Studio which runs on Windows and Mac.

Microsoft’s recent push towards “any device” support implies a need for something that allows developers to use a Microsoft platform, either in the cloud or on-premise, to create apps for iOS and Android. The evidence is that Xamarin is a key partner for this support. Xamarin was prominent at Microsoft’s 2014 Build conference. In addition, Microsoft has open-sourced most of .NET, including the next generation of the C# compiler, which means that Mono and Xamarin can increasingly use the same code as Microsoft .NET. These factors make Xamarin a strong choice for existing Microsoft platform developers.

Find Out More

More details on the Grey Matter website. To discuss your development options further, call Grey Matter on 01364 654100 or email