By Jim Wilson
Building apps for mobile devices presents an interesting challenge because there are two dominant platforms: iOS
. Combined, these two platforms have a worldwide market share exceeding 90 percent, so for a mobile app to be successful, it needs to be cross-platform, supporting both. Unfortunately, from a developer’s perspective, these platforms have very little in common. When building a cross-platform app we need to balance between two opposing needs. On one side, we want to share as much code as possible, so we’re not doing redundant work. On the other side, we want our app to have a look and feel that’s familiar to users; the iOS version of our app should have a look and feel appropriate for iOS and vice versa for Android.
The Developer’s Challenge
iOS and Android are both mobile operating systems based on variations of Unix
but that’s where the similarities end. The most obvious difference is the preferred programming languages. The iOS platform primarily uses Objective-C
, and more recently Swift
, whereas Android relies primarily on Java
. The programming language differences are just the beginning. Each platform has a different event model, security model and UI model. The platforms even have different process and resource management behaviors. With so many differences, finding an effective approach to cross-platform development is a challenge. Building the apps separately using the standard tools for each platform was the most common approach for a long time. It provides full access to all platform features but results in a full 2X development effort. Following an approach that requires two completely separate development efforts to create a single product isn’t practical for most organizations. Thankfully, today, we have other options.
Tools With High-Level Abstractions
There are a number of tools that provide high-level abstractions that hide the details of the underlying platforms. Tools in this category include PhoneGap
(also known as Cordova), Appcelerator
and a few others. Many of these tools allow you to work with familiar technologies such as HTML
. These environments map platform features and events to the tool’s custom model, making it relatively easy to share code between platforms. The challenge with the tools in this category comes up when creating a single app that has separate looks on iOS and Android. Adding this kind of per-platform behavior tends to be difficult. If you need to access platform-specific features not available through the tools, you have to extend the tools, which can also be difficult. To create these extensions, you’ll need to have skills in the standard languages and tools of both iOS and Android.
Tools With a Common Programming Model and Minimal Abstraction
There are a few tools that provide a programming language and class library that work across both platforms while still providing access to the unique features and behaviors of each platform. The most popular tool in this class is Xamarin
. Xamarin allows developers to write iOS and Android applications using the C#
programming language and .NET Base Class Library (BCL). Code related to things like business logic, communications and other similar behaviors can be shared between iOS and Android apps. Xamarin also includes bindings to the underlying features of each platform, which allows the apps produced with Xamarin to look, feel and behave just as apps created with the standard iOS and Android tools. All Xamarin code, whether platform specific or shared, is written in C#. Historically, the approach to developing apps with Xamarin was to divide the application development into UI and non-UI code, with only the non-UI code being shared. In mid-2014, this began to change with the introduction of Xamarin Forms
, a UI library that provides a common UI model for both iOS and Android. Xamarin Forms is backed by both platforms’ native components, which gives apps an appropriate look on each platform. Xamarin Forms does not completely eliminate the need for platform-specific UI code, but it does reduce it. As we’ve seen, iOS and Android have a number of significant differences, and development tools offer varying approaches to dealing with these differences. To work effectively, you’ll need to decide which is more important to you: code sharing or platform-specific feature access. Once you make that decision, get started working with the tool that fits that decision best. Jim Wilson creates courses on mobile app development for Pluralsight, the leading provider of online training for technology professionals. He is the lead mobile developer for Spectafy, a startup providing community driven, location-specific, real-time information and photos. He is also president of JW Hedgehog, Inc., a consulting firm specializing in solutions for the Android, iOS and Microsoft platforms. Jim has over 30 years of software development experience with the past 14 years focused primarily on mobile and location-based solutions.
Image: Robert Kneschke/Shutterstock.com
Upload Your ResumeEmployers want candidates like you. Upload your resume. Show them you're awesome.