Appearance
SOC-0030: Build an Android UI Bridge for Swift
Project size: 3 months
Estimated difficulty: Hard
Recommended Skills
- 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:
- Design a lightweight "widget" layer that maps Android
Viewtypes to Swift classes generated by Java2Swift. - Implement a renderer that plugs into Tokamak’s reconciler, performing diff‑based updates on the Android UI thread.
- Package the bridge as a SwiftPM library deliverable as a
.sofor 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:
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
AndroidTokamakRendererwith clear installation docs. - Gradle helper plugin that downloads the compiled
.soand wiresSystem.loadLibrary. - Sample app showcasing a small Tokamak demo compiled & running on an emulator/device.
Stretch Goals
- Support for Jetpack Compose’s
androidx.compose.uiruntime 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.