Lesson 9 · Mobile apps

How mobile apps are built

Native, cross-platform and web apps: how each works and when to choose it.

About 20 minutes

Tab indents. Press Escape, then Tab, to leave the editor.

"We need an app" is one of the most common requests in software, and one of the most expensive to get wrong. There are three broad ways to build for phones: native apps written separately for each platform, cross-platform apps that share code between iOS and Android, and web apps that run in the browser. Each is the right answer for some products. This lesson explains how each one works under the hood, what it costs, and how apps get from a developer's laptop onto people's phones, so you can follow (and contribute to) the conversation when a team picks one.

Two platforms, two toolkits

Nearly every smartphone runs one of two operating systems: Apple's iOS (and iPadOS on iPads) or Google's Android, which is open source and used by many manufacturers. Each platform has its own languages, user interface toolkit, design conventions and app store.

iOSAndroid
Main languageSwiftKotlin
Modern UI toolkitSwiftUIJetpack Compose
Older UI toolkit, still commonUIKit (Swift or Objective-C)Views (Kotlin or Java)
Development toolXcode, which runs only on macOSAndroid Studio, on macOS, Windows or Linux
Design guidanceHuman Interface GuidelinesMaterial Design
StoreApp StoreGoogle Play, plus other stores

Both modern toolkits are declarative: you describe what the screen should look like for the current state, and the framework updates the screen when the state changes. If you've used React on the web, the idea is the same. Here's the same small screen in each.

SwiftUI:

import SwiftUI

struct PackingView: View {
    @State private var bottles = 0

    var body: some View {
        VStack(spacing: 16) {
            Text("Water bottles packed: \(bottles)")
            Button("Add one") {
                bottles += 1
            }
            .buttonStyle(.borderedProminent)
        }
        .padding()
    }
}

Jetpack Compose:

@Composable
fun PackingScreen() {
    var bottles by remember { mutableIntStateOf(0) }

    Column(
        modifier = Modifier.padding(16.dp),
        verticalArrangement = Arrangement.spacedBy(16.dp),
    ) {
        Text("Water bottles packed: $bottles")
        Button(onClick = { bottles++ }) {
            Text("Add one")
        }
    }
}

@State in Swift and remember { mutableIntStateOf(0) } in Kotlin both say "this value belongs to the screen; redraw when it changes". VStack and Column stack children vertically, much like a flexbox column.

Native: one app per platform

A native app is written with the platform's own language and toolkit. Its controls are the system's real controls, so it looks and behaves exactly as people expect on that device, and it gets new platform features (widgets, new camera or health APIs, a redesigned system look) as soon as Apple or Google ships them.

The cost is that iOS and Android are separate codebases, usually with separate specialists. Every feature is built, tested and fixed twice. Large companies with big mobile teams, and apps that depend on deep device integration or top performance, often choose native anyway.

Cross-platform: share code across platforms

Cross-platform frameworks let one team share most of the code between iOS and Android. They differ in what is shared and how the interface reaches the screen.

  • React Native (created at Meta) lets you write the app in JavaScript or TypeScript with React. Your components are turned into the platform's real native views, so a <Text> becomes a real iOS or Android text view. It's a natural fit for teams that already know React; the React Native docs recommend starting with the Expo framework, which handles much of the build and update tooling.
  • Flutter (created at Google) uses the Dart language and draws every pixel itself with its own rendering engine, rather than using the platform's controls. That gives pixel-identical interfaces on every platform, and it means Flutter apps have to imitate platform conventions rather than inheriting them.
  • Kotlin Multiplatform (from JetBrains, the makers of Kotlin) shares business logic such as data models, networking and storage, written in Kotlin, while each platform can keep its own native interface. Compose Multiplatform extends that to sharing Jetpack Compose interfaces across Android, iOS and desktop, and more recently the web.
  • .NET MAUI from Microsoft does the same job for teams that work in C#.

Here's the packing screen in React Native, for comparison:

function PackingScreen() {
  const [bottles, setBottles] = useState(0)

  return (
    <View style={{ padding: 16, gap: 16 }}>
      <Text>Water bottles packed: {bottles}</Text>
      <Button title="Add one" onPress={() => setBottles(bottles + 1)} />
    </View>
  )
}

Sharing code isn't all-or-nothing. A common middle path is a shared core of logic and data with a native interface on each platform. OfflineOwl's own native apps are built this way: a shared core written in Rust handles storage, the library and search, and each platform gets its own interface, in SwiftUI for iPhone, iPad and Mac and in Compose Multiplatform for Android, Windows and Linux.

Question

Quick check

Which framework draws its own interface with its own rendering engine, instead of using the platform's built-in controls?
Pick an answer.

The web, and progressive web apps

A website built mobile-first already works on every phone, with no app store, no install and instant updates: you deploy and everyone has the new version. A progressive web app (PWA) goes further. With a web app manifest (a JSON file with the app's name, icons and colors) and a service worker (a script that can answer requests from a cache, covered in the next lesson), a site can be installed to the home screen, open in its own window and work offline.

The limits are mostly about reach into the device and discoverability. Browsers expose fewer device features than native toolkits do, and Safari on iOS supports fewer of them than Chrome on Android. People also tend to look for apps in app stores rather than install them from a browser. A hybrid option sits in between: tools such as Capacitor wrap a web app in a native shell, with plugins for device features, so it can be published to the stores.

Choosing an approach

If the product needsLean towards
The best performance, deepest device integration, newest platform featuresNative
One team shipping to iOS and Android, sharing most codeReact Native, Flutter or Kotlin Multiplatform
An existing React web team to build the appReact Native
Shared logic but fully native-feeling screensA shared core (such as Kotlin Multiplatform) with native UIs
The widest reach, no install, instant updatesA responsive web app or PWA

In practice, the team you have matters as much as the technology. A company of React developers will usually ship faster with React Native than by hiring Swift and Kotlin specialists, and vice versa.

Question

Quick check

A small charity's web team (who know React) needs an app in both stores within a few months, mainly lists, forms and a map. What's the most sensible starting point?
Pick an answer.

From code to someone's phone

Getting a mobile app into people's hands is a process of its own, quite different from deploying a website.

Step by step

Shipping a mobile app

Build and run locally

Developers run the app in a simulator (iOS, from Xcode) or an emulator (Android, from Android Studio) on their computer, and on real devices connected by cable or Wi-Fi. Building for iOS requires a Mac, because Xcode only runs on macOS.

1 / 6

Recap

  • iOS apps are written in Swift with SwiftUI (or UIKit); Android apps in Kotlin with Jetpack Compose (or Views). Both modern toolkits are declarative.
  • Native apps give the best platform fit and newest features at the cost of two codebases.
  • React Native uses real native views from JavaScript; Flutter draws its own UI; Kotlin Multiplatform and Compose Multiplatform share logic and, optionally, UI.
  • Web apps and PWAs reach every device with instant updates but less device access and no store presence by default.
  • Shipping means signing, beta testing, store listings, review and gradual rollouts, and supporting old versions after release.

Finished this lesson?

Mark it complete to track your progress on this device.