Skip to content

SOC-0030: Build an Android UI Bridge for Swift

Project size: 3 months

Estimated difficulty: Hard

  • Strong proficiency in Swift (including generics, macros, and SwiftPM plugins)
  • Solid understanding of Android‑level UI APIs (android.view.*, android.widget.*)
  • Experience with JNI and/or swift‑java/JavaKit
  • Familiarity with SwiftUI or Tokamak rendering internals
  • Basic knowledge of Gradle/AGP and Android build tooling

Description

Swift is rapidly expanding beyond Apple platforms. Thanks to swift‑java, it is now possible to call Java APIs directly from Swift—but there is no ergonomic UI abstraction for Android yet.

This project will create a first‑class bridge that lets Swift code instantiate and manipulate native Android View hierarchies, while exposing them to the SwiftUI declarative framework Tokamak.

Concretely, you will:

  1. Design a lightweight "widget" layer that maps Android View types to Swift classes generated by Java2Swift.
  2. Implement a renderer that plugs into Tokamak’s reconciler, performing diff‑based updates on the Android UI thread.
  3. Package the bridge as a SwiftPM library deliverable as a .so for embedding in a standard Gradle project, with helper Gradle scripts to bundle Swift stdlib slices.

By the end of the summer, anyone should be able to write:

main.swift
swift
@main
struct Hello: View {
   var body: some View {
      VStack {
         Text("Hello, Android!")
         Button("Tap me") { print("🍻") }
      }
      .padding()
   }
}

…and see it run natively inside an Activity, rendered by pure Swift.

Expected Results

  • Working renderer that covers core primitives (TextView, Button, LinearLayout, FrameLayout, image loading, basic theming) and supports state updates & layout passes.
  • SwiftPM package AndroidTokamakRenderer with clear installation docs.
  • Gradle helper plugin that downloads the compiled .so and wires System.loadLibrary.
  • Sample app showcasing a small Tokamak demo compiled & running on an emulator/device.

Stretch Goals

  • Support for Jetpack Compose’s androidx.compose.ui runtime as an alternative backend.
  • Hot‑reload/dev‑server that mirrors Swift file changes directly onto the device.
  • VS Code / Xcode template that bootstraps a ready‑to‑run Android‑Swift workspace.