If you want to deliver your app across different platforms you have to overcome some obstacles. Some challenges are easier to overcome than others:
Programming Language
By now you will have noticed that most mobile platforms release their own SDKs, which enable you to develop apps in the platforms’ supported programming languages.
However, these languages tend to belong to one of a few families of root languages and the following table provides an overview of these and the platforms they are supported on:
B
Y
Going Cross-Platform
Language Supported Natively 1 Supported Optionally 2
C, C++ Sailfish OS, Ubuntu, Windows
Android (partially, using the NDK), iOS (partially) C# & Visual Basic Windows none
Java Android none JavaScript Tizen, Ubuntu,
Windows
none Objective-C iOS none Swift iOS none
Cross platform frameworks can overcome the programming language barriers in different ways:
— Web Technologies: This approach exploits the fact that most platforms provide direct support for web technologies through embedded ‘webviews’ in native applications. Along with HTML and CSS, this approach supports JavaScript as well.
— Interpretation/Virtual Machine: Here the framework delivers an engine for each platform that interprets a common or framework specific language. For example, a popular option for games development is Lua scripting.
1 for example either the primary or only language for creating applications
2 for example can be used as an alternative to the native language but generally
Going Cross-Platform
— Cross Compilation: The holy grail of cross platform frame- works is cross compilation, but it is also the most complex technical solution. It enables you to write an app in one language and have it transcoded into each platform's native language, offering native runtime speed.
Most frameworks also provide a set of cross platform APIs that enable you to access certain platform or device features, such as a device’s geolocation capabilities, in a common way. For features such as SMS messaging you can also use network APIs that are device-independent.
OS Versions
Platforms evolve and sooner or later they will be version specific features that you want to leverage. This adds another layer of complexity to your app and also a challenge for cross-platform tools: sometimes they lag behind when a new OS version is released.
UI and UX
A difficult hurdle for the cross platform approach is created by the different User Interface (UI) and User Experience (UX) patterns that prevail on individual platforms.
Nowadays most platforms use a variation of the flat design as pioneered by Windows Phone in 2007. However there are many differences and subtleties between the platforms, so porting over the exact same look and feel would result in an awkward looking app on other platforms.
Another key challenge with a uniform cross-platform UI is that it can behave differently to the native UI users are familiar with, resulting in your application failing to “work” for users. A simple example is not to support a hardware key such as the back key on a given platform correctly. Another challenge is the "uncanny valley" that results from mimicking
Going Cross-Platform
native UI elements that look but do not work the same. Instead of mimicking native controls you should either use non-native looking ones or just use the 'real deal' and go native.
When you target end consumers directly (B2C), you often need to take platform specific user experience much more into account than in cases when you target business users (B2B). In any case you should be aware that customising and tailoring the UI and UX to each platform can be a large part of your application development effort and is arguably the most challenging aspect of a cross platform strategy.
Desktop Integration Support
Integration of your application into devices’ desktops / home screens varies a lot between the platforms; on iOS you can only add a badge with a number to your app’s icon, on Windows you can create live tiles that add structured information to the desktop, while on Android you can add a full-blown desktop widget that may display arbitrary data and use any visuals.
Using desktop integration might improve the interaction with your users drastically.
Multitasking Support
Multitasking enables background services and several apps to run at the same time. Multitasking is another feature that is realised differently among operating systems. On Android, Ubuntu and Sailfish OS there are background services and you can run several apps at the same time; on Android it is not possible for the user to exit apps as this is handled automati- cally by the OS when resources run low. On iOS and Windows we have a limited selection of background tasks that may continue to run after the app’s exit. So if background services can improve your app’s offering, you should evaluate cross
Going Cross-Platform
platform strategies carefully to ensure it enables full access to the phone’s capabilities in this regard.
Battery Consumption And Performance
Closely related to multitasking is the battery usage of your application.
While CPU power is roughly doubled every two years (Moore’s law says that the number of transistors is doubled every 18 months), by contrast battery capacity is doubling only every seven years. This is why smartphones like to spend so much time on their charger. The closer you are to the platform in a crossplatform abstraction layer, the better you can control the battery consumption and performance of your app. As a rule of thumb, the longer your application needs to run in one go, the less abstraction you can afford.
Also some platforms have a great variety of performance, most notably Android - Android devices range from painfully slow to über-fast.
Push Services
Push services are a great way to give the appearance that your application is alive even when it is not running. In a chat application you can, for example, send incoming chat messages to the user using a push mechanism. The way push services work and the protocols they use, again, are realised differently and use different data sizes on each platform.
Going Cross-Platform In App Purchase
Today's most important monetisation option is in-app purchases. Needless to say that this works differently across platforms. See the monetisation and the platform-specific chapters for details.
In App Advertisement
There are different options for displaying advertisements within mobile apps, some are vendor independent third-party solutions. Platform specific advertisement services, however, can offer better revenues. Again, these vendor services work differently between the platforms. The monetisation chapter in this guide provides more information on this topic as well.
Cross-Platform Strategies
This section outlines some of the strategies you can employ to implement your apps on different platforms.
Going Cross-Platform Direct Support
You can support several platforms by having a specialized team for each and every target platform. While this can be resource intensive, it will most likely give you the best integration and user experience on each system. An easy entry route is to start with one platform and then progress to further platforms once your application proves itself in the real world.
Component libraries can help you to speed up native development, there are many commercial and open source components available for all platforms.
Asset Sharing
When you maintain several teams for different platforms you can still save a lot of effort when you share some application constructs:
— Concept and assets: Mostly you will do this automatically: share the ideas and concepts of the application, the UI flow, the input and output and the design and design assets of the app (but be aware of the need to support platform specific UI constructs).
— Data structures and algorithms: Go one step further by sharing data structures and algorithms among platforms.
— Code sharing of the business model: Using cross platform compilers you can also share the business model between the platforms. Alternatively you can use an interpreter or a virtual machine and one common language across a variety of platforms.
— Complete abstraction: Some cross platform tools enable you to completely abstract the business model, view and control of your application for different platforms.
Going Cross-Platform Player And Virtual Machines
Player concepts typically provide a common set of APIs across different platforms. Famous examples include Xamarin1 and
Lua2. This approach makes development very easy. You are
dependent, however, on the platform provider for new features and the challenge here is when those features are available on one platform only. Sometimes player concepts use a “least common denominator” approach to the offered features, to maintain commonality among implementations for various platforms.
Cross Language Compilation
Cross language compilation enables coding in one language that is then transformed into a different, platform specific language. In terms of performance this is often the best cross platform solution, however there might be performance dif- ferences when compared to native apps. This can be the case, for example, when certain programming constructs cannot be translated from the source to the target language optimally.
There are three common approaches to cross language compilation: direct source to source translation, indirectly by translating the source code into an intermediate abstract language and direct compilation into a platform’s binary format. The indirect approach typically produces less readable code. This is a potential issue when you would like to continue the development on the target platform and use the translated source code as a starting point.
1 xamarin.com
Going Cross-Platform (Hybrid) Web Apps
Hybrid web development means to embed a webview within a native app. The standard for hybrid apps is the open source tool Apache Cordova3 (formerly known as PhoneGap). This
approach allows you to access native functionality from within the web parts of your apps and you can also use native code for performance or user experience critical aspects of your app. Hybrid apps allow you to reuse the web development parts across your chosen platforms. Read the web chapter to learn more about mobile web development.
ANSI C
While HTML and web programming starts from a very high ab- straction you can choose the opposite route using ANSI C. You can run ANSI C code on all important platforms like Android, iOS and Windows. The main problem with this approach is that you cannot access platform specific APIs or even UI controls from within ANSI C. Using C is mostly relevant for complex algorithms such as audio encoders. The corresponding libraries can then be used in each app project for a platform.
Going Cross-Platform