Repository navigation
feat(mobile): iOS and Android support for Wails v3 (experimental) - #5562
Merged
Merged
Conversation
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
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 samemain.gobuilds for desktop, iOS and Android.WKWebView, assets in-process over awails://scheme.WebView, assets in-process viaWebViewAssetLoader; Go compiled aslibwails.so(JNI) and hosted by a small JavaMainActivity/WailsBridge.Both platforms are flagged Experimental in the docs.
What works (verified on simulator / emulator)
wails://(WKURLSchemeHandler)WebViewAssetLoaderevents.IOS.*events.Android.*:fatHighlights
Compile health —
GOOS=iosandGOOS=androidbuild again (debug + production). Key gotcha fixed:GOOS=iosimplies thedarwintag andGOOS=androidimplies thelinuxtag, so desktop-only files were leaking into mobile builds (build-tag sweep acrosspkg/applicationand several services).Runtime correctness
wails:runtime:readyhandshake can't be lost; removed a fixed 2s startup sleep and a per-call C-string leak.fetch()POST bodies toshouldInterceptRequest, so the default HTTP runtime transport crashed on a nil body — added a JavascriptInterface transport (nativeHandleRuntimeCall, responses viawindow._wailsAndroidCallback); the bundled runtime auto-installs it when the bridge is present.Events —
tasks/events/generate.gonow emits both iOS and Android event mappings fromevents.txt(a latentvar iOSin the template that would re-breakGOOS=ioson regen is fixed tovar IOS).Tooling & docs —
wails3 doctorreports Xcode/iOS SDKs and the Android SDK/NDK/JDK; newIOS.md/ANDROID.mdand 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
wails3 generate bindingsfor mobile emits cosmetic[warn]typecheck noise (host tags bleeding into the cross-compile typecheck); bindings generate correctly..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
Bug Fixes
Documentation