Skip to content

Chapter 22: Mobile Development

Wyn compiles to native iOS and Android apps. No JavaScript bridge, no virtual machine - real native code.

Your First iOS App

wyn
// Mobile SDK stubs - resolved by the platform shell when packaged;
// declaring them keeps the app buildable and testable on your desktop.
fn wyn_ui_text(ctx: int, text: string, size: int) {}
fn wyn_ui_button(ctx: int, label: string, id: int) {}
fn wyn_ios_main(a: int, b: int) -> int { return 0 }

fn wyn_app_title() -> string {
    return "Hello Wyn"
}

fn wyn_app_build(ctx: int) {
    wyn_ui_text(ctx, "Welcome!", 28)
    wyn_ui_button(ctx, "Tap Me", 1)
}

fn wyn_on_button(id: int) {
    println("Tapped!")
}

fn main() -> int {
    return wyn_ios_main(0, 0)
}

Cross-compile it (requires Xcode's iOS SDK):

bash
wyn cross ios app.wyn
# Produces app.wyn.ios (arm64, min iOS 15)

Android

Requires the Android NDK (Android Studio → SDK Manager → NDK):

bash
wyn cross android app.wyn
# Produces app.wyn.android (arm64)

UI Components

  • wyn_ui_text(ctx, text, size) - display text (maps to UILabel on iOS)
  • wyn_ui_button(ctx, title, id) - tappable button (maps to UIButton)
  • wyn_ui_spacer(ctx, height) - vertical spacing

Mobile APIs

Provided by the platform shell (stub them like the UI functions for desktop builds):

wyn
// Persistent storage
wyn_storage_set("key", "value")
var val = wyn_storage_get("key")

// Clipboard
wyn_clipboard_set("text")
var text = wyn_clipboard_get()

// Notifications & haptics
wyn_notify("Title", "Body")
wyn_vibrate()

Fast Iteration

bash
wyn watch app.wyn

Edit your code → save → wyn watch rebuilds and reruns automatically. Develop the app logic on your desktop with stubs, then wyn cross ios/android to package for device.

MIT License - v1.19.1