Hello Swift Community !
I have recently explored how to share code between fully native iOS and Android apps (Swift & Kotlin) and I'm currently evaluating if WebAssembly that would reuse our swift code would be a viable solution. The ultimate goal (dream ?) would be to have a single swiftWasm code-base that would consist of our current swift code and call to native APIs on iOS & Android to have access to Bluetooth, Geolocation etc...
For now I see 2 main issues :
-
For me the most problematic thing would be the UI. Currently almost all of our screens are made in SwiftUI. I think we all agree SwiftUI should have been open source from the start & decoupled from UIKit/AppKit but sadly it isn't. Is there a stable, production ready UI lib out there that can take SwiftUI code and render it properly in WebAssembly ?
- Tokamak looked promising & is referenced in Swift Wasm docs (GitHub - TokamakUI/Tokamak: SwiftUI-compatible framework for building browser apps with WebAssembly and native apps for other platforms) but doesn't seem under active development anymore, last commit dating back early 2023
- OpenSwiftUI (GitHub - OpenSwiftUIProject/OpenSwiftUI: [WIP] Open source implementation of Apple's SwiftUI.) seems under development but Readme warns not to use in production because it uses hidden Apple APIs
- swift-cross-ui (GitHub - stackotter/swift-cross-ui: A cross-platform declarative UI framework, inspired by SwiftUI.) is also a work in progress but I'm not sure it's made to work on WebAssembly
-
There is also the issue of integration & interoperability with Apple / Android APIs or other parts of app that would still be native for example for BLE connection. We can integrate .wasm in WKWebview but how can we interact both ways between iOS/Android and Wasm code ?
Keep in mind I've a solid experience with Swift but I'm completely new to WebAssembly so I may be missing something obvious here ^^
If anyone has already attempted something like this, feel free to share ;)
Thank you