Skip to content

feat(mobile): iOS and Android support for Wails v3 (experimental) - #5562

Merged
leaanthony merged 64 commits into
masterfrom
feat/mobile-support
Jun 13, 2026
Merged

leaanthony merged 64 commits into
masterfrom
feat/mobile-support

Conversation

@leaanthony

@leaanthony leaanthony commented Jun 10, 2026 •

Copy link
Copy Markdown
Member

Draft / experimental. Mobile (iOS + Android) support for Wails v3, verified live on the iOS Simulator and the Android emulator. Opening as a draft for review.

Summary

Brings iOS and Android from partially-scaffolded to working, verified mobile targets with the same runtime surface as desktop — service bindings, events (both directions), dialogs, clipboard and screens all route through the standard @wailsio/runtime. The same main.go builds for desktop, iOS and Android.

  • iOS — native UIKit app, WKWebView, assets in-process over a wails:// scheme.
  • Android — native app, Android WebView, assets in-process via WebViewAssetLoader; Go compiled as libwails.so (JNI) and hosted by a small Java MainActivity/WailsBridge.

Both platforms are flagged Experimental in the docs.

What works (verified on simulator / emulator)

Area iOS Android
In-process asset serving ✅ wails:// (WKURLSchemeHandler) ✅ WebViewAssetLoader
Service bindings (JS→Go) ✅ ✅ (JavascriptInterface transport)
Events (Go→JS / JS→Go) ✅ ✅
Message dialogs ✅ UIAlertController ✅ AlertDialog
Open file/files ✅ UIDocumentPicker ✅ Storage Access Framework
Open dir / save file dir ✅ / save ❌ (errors) both ❌ (error with guidance)
Clipboard ✅ UIPasteboard ✅ ClipboardManager
Screens (incl. safe-area / insets) ✅ UIScreen ✅ WindowMetrics
Lifecycle events ✅ events.IOS.* ✅ events.Android.*
Device builds + signing ✅ devicectl / IPA ✅ keystore-signed APK / :fat

Highlights

Compile health — GOOS=ios and GOOS=android build again (debug + production). Key gotcha fixed: GOOS=ios implies the darwin tag and GOOS=android implies the linux tag, so desktop-only files were leaking into mobile builds (build-tag sweep across pkg/application and several services).

Runtime correctness

  • iOS: the page no longer loads twice at startup, so the wails:runtime:ready handshake can't be lost; removed a fixed 2s startup sleep and a per-call C-string leak.
  • Android: the WebView does not deliver fetch() POST bodies to shouldInterceptRequest, so the default HTTP runtime transport crashed on a nil body — added a JavascriptInterface transport (nativeHandleRuntimeCall, responses via window._wailsAndroidCallback); the bundled runtime auto-installs it when the bridge is present.

Events — tasks/events/generate.go now emits both iOS and Android event mappings from events.txt (a latent var iOS in the template that would re-break GOOS=ios on regen is fixed to var IOS).

Tooling & docs — wails3 doctor reports Xcode/iOS SDKs and the Android SDK/NDK/JDK; new IOS.md / ANDROID.md and docs-site guides; device/release build tasks (iOS signing/entitlements/IPA, Android keystore signing + fat APK).

Commits

The first commit seeds the iOS/Android command-template scaffolding; the remaining 9 are the iOS (6) and Android (3) feature commits.

Notes / known limitations

  • Only the first window is displayed (mobile is single-window/fullscreen); window geometry, menus and system tray are intentional no-ops.
  • Save-file dialogs (both platforms) and choose-directory (Android) return an explicit error — write into the app sandbox instead.
  • wails3 generate bindings for mobile emits cosmetic [warn] typecheck noise (host tags bleeding into the cross-compile typecheck); bindings generate correctly.
  • App Store / Play Store submission uses the generated Xcode project (iOS) or your own keystore / Android Studio for an .aab (Android).

Verification

iOS Simulator (Xcode 26.5) and Android emulator (API 34, arm64): assets load, JS→Go bindings render, Go→JS events tick, native dialogs show, clipboard round-trips, device/screen info return real data, and stripped production builds install and launch.

Summary by CodeRabbit

  • New Features

    • First-class iOS & Android support: simulator/emulator + device workflows, APK/IPA packaging & signing, example mobile app, native dialogs, file pickers, clipboard, haptics/vibrate, toast, and main-thread UI callbacks.
    • Runtime: device info, real screen metrics, typed Android lifecycle & WebView events, Android JS bridge transport.
  • Bug Fixes

    • Multiple stability and startup fixes for iOS/Android runtimes, event delivery, and JS↔native messaging.
  • Documentation

    • Added comprehensive iOS/Android guides, examples, porting notes, and tooling doctor updates.

Baseline iOS/Android command-template directories that the mobile support
commits build upon (wails3 project scaffolding for mobile targets).
- export events.IOS (was unexported iOS; events_common_ios.go references it)
- define androidMethodNames stub on ios (messageprocessor.go references it
  unconditionally; mobile_stub is !ios && !android)
- examples/ios: bindings generate to ./bindings/ios-example (module name),
  not the template default ./bindings/changeme
Core fixes:
- single initial navigation: drop hardcoded loadRequest in viewDidLoad and
  manual loadView/viewDidLoad calls (page loaded twice, losing the
  wails:runtime:ready handshake); Go's window run() now loads the start URL
- runtime-ready hardening: first /wails/runtime request marks the window
  ready, so Go->JS events/ExecJS work even if the postMessage handshake is
  dropped during load
- replace the 2s startup sleep with a launch signal from the app delegate;
  ApplicationDidFinishLaunching is emitted Go-side after listeners are wired
- real hasListeners backed by a Go registry fed from app/window .on();
  delete pkg/events events_ios.go (duplicate C symbol + OOB array)
- free the C string in execJS (leaked on every Go->JS call)

Features:
- dialogs: UIAlertController message dialogs with button callbacks;
  UIDocumentPickerViewController open file/files/directory (files imported
  as sandbox copies); save dialogs return an explicit unsupported error
- clipboard: UIPasteboard-backed setText/text
- screens: real UIScreen metrics (points, pixels, scale, safe-area work area)

Hygiene:
- framework diagnostics gated behind debug builds (Go const + native
  WailsVLog); production builds are quiet
- GOOS=ios now compiles all of ./pkg/...: notifications/dock/updater/mac/
  doctor-ng darwin files no longer leak into iOS builds (ios implies the
  darwin build tag); added iOS fallbacks where needed
…ectl deploy

- Taskfile platform parameterisation: IOS_PLATFORM=simulator|device picks
  SDK (iphonesimulator|iphoneos), target triple and version-min flags;
  MIN_IOS_VERSION configurable (also via ios.minIOSVersion in config.yml,
  templated into Info.plist); armv7 dropped from UIRequiredDeviceCapabilities
- CODESIGN_IDENTITY (default ad-hoc), optional PROVISIONING_PROFILE embedded
  into device bundles, entitlements applied to device builds only (simulator
  bundles with entitlements are refused by SpringBoard - found the example's
  stale macOS-keyed entitlements.plist doing exactly that; replaced template
  and example with iOS-appropriate content)
- package now links the executable (the old flow shipped whatever stale
  binary happened to be in bin/), package:ipa produces a Payload zip,
  deploy-device installs+launches via xcrun devicectl
- fix webview_window_darwin_production.go build tag: production iOS builds
  never compiled (tag matched ios via implied darwin)
- ensure-simulator no longer hardcodes 'iPhone 15 Pro' when creating a device

Verified: simulator production package installs+launches with working
events/dialogs/bridge; device package produces LC_BUILD_VERSION platform 2
(PLATFORM_IOS) minos 15.0 binary; ipa contains signed Payload bundle.
…h scripts

- IOS.md: accurate status matrix, simulator/device quickstart, signing and
  IPA flow, config keys, porting notes; replaces the drifted
  IOS_ARCHITECTURE/IOS_RUNTIME/IOS_FEATURES_TODO docs
- examples/ios README: iOS quickstart section
- wails3 doctor now reports Xcode and iOS simulator/device SDKs on macOS
- delete repo-root scratch artifacts: build_ios.sh, test-new-ios-build.sh,
  verify-ios-setup.sh, fix-darwin-ios-constraints.sh, test-ios-compilation.go,
  test-assets/
- new Building & Packaging guide at /guides/build/ios (experimental badge):
  simulator/device workflow, signing, IPA, configuration, status matrix,
  porting notes; registered in the sidebar
- iOS entries in UNRELEASED_CHANGELOG.md (Added + Fixed)

Verified: astro build succeeds (1387 pages) and emits /guides/build/ios/.
…/haptics

- events: generate iOS+Android event mappings from events.txt (generate:events
  now emits var IOS/var Android blocks, android: entries in eventToJS and
  event_types.ts; .m post-processing preserves blank lines; template carried
  the old 'var iOS' name that broke GOOS=ios builds on regen)
- fix build-tag leaks into GOOS=android: linux_cgo.c/.h, events_linux.go/.h,
  environment_linux.go now carry !android (android implies the linux tag);
  delete dead pkg/events/events_android.go (out-of-bounds MAX_EVENTS array)
- application_android.go rewrite: generic JNI call layer (attach/detach safe,
  exception-checked, leak-free), logcat-routed logging gated by
  androidVerboseLogging (debug/production consts), typed lifecycle events
  (ActivityCreated/Started/Resumed/Paused/Stopped/LowMemory, WebViewPage*),
  setupCommonEvents wired in the cgo path, launch event emitted after
  listener registration
- runtime handshake fixed: JS invoke messages route into windowMessageBuffer
  (plain 'wails:runtime:ready' passthrough mirrors iOS HandleJSMessage) +
  synthetic ready on first /wails/runtime request; the old broken
  runtime.Core() injection at onPageFinished is gone (the bundled runtime
  self-detects the Android JavascriptInterface at document start)
- real dialogs (AlertDialog with button-role mapping + >3-button list,
  SAF document picker with copy-to-cache for real paths; save dialogs error
  with guidance), clipboard (ClipboardManager), screens (WindowMetrics +
  system-bar insets, dp/px split), main-thread dispatch (main looper),
  haptics/toast/device-info runtime methods
- Java bridge: lifecycle forwarding (onStart/Stop/LowMemory), file picker
  via ACTION_OPEN_DOCUMENT, debug-gated logging, VIBRATE permission;
  synced across internal/commands, build_assets and examples
- nocgo variant kept API-identical for tooling builds (bindings generation)
… wiring

The Android WebView does not deliver fetch() POST bodies to
shouldInterceptRequest, so the default HTTP runtime transport never reached
Go (a bindings call SIGSEGV'd reading a nil request body). Add an Android
transport that routes runtime calls through window.wails.invokeAsync to a new
nativeHandleRuntimeCall JNI export, with responses delivered via
window._wailsAndroidCallback. The runtime auto-installs it when the
JavascriptInterface bridge is detected (internal/runtime .../runtime.ts).

- nativeHandleRuntimeCall → handleRuntimeCallForAndroid: parses the call
  envelope and drives a per-app MessageProcessor, returning
  {ok,data|text|error}
- serveAssetForAndroid now sets req.Body = http.NoBody (handlers reached via
  ServeHTTP assume the server's non-nil-Body guarantee)
- WailsJSBridge.invokeAsync rewired to handleRuntimeCall; callback target is
  window._wailsAndroidCallback
- populate ScreenManager at startup + lazily (LayoutScreens), matching the
  desktop platforms — Screens.GetAll returned nil before; screen_android.go
  now supplies PhysicalWorkArea so WorkArea scales correctly

Verified on the API 34 arm64 emulator: assets load, JS→Go bindings render
'Hello Android!', Go→JS time events tick, native AlertDialog shows, clipboard
round-trips, Device.Info + Screens.GetAll return real data (412x915 dp,
WorkArea 412x839).
- ANDROID.md: status matrix, quickstart, signing/release, porting notes,
  architecture; replaces the pre-implementation ANDROID_ARCHITECTURE.md
  scratch doc
- docs site: guides/build/android page (Experimental badge) + sidebar entry
- wails3 doctor: report Android SDK, platform-tools, NDK and JDK (cross-platform)
- examples/android: README pointing at ANDROID.md
- changelog: Added/Fixed Android entries
@coderabbitai

coderabbitai Bot commented Jun 10, 2026 •

Copy link