Swift Wasm for mobile cross-platform development?

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 :

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

2 Likes

I can't help you with the cross-platform UI, but I maintain an open source Android SDK for Swift that you can try using to build business-logic Swift code for Android. Some people do that and use JNI to invoke the native Android UI and other APIs in Java or Kotlin. Also, there is work underway to make Android an officially-supported platform for Swift.

1 Like

Thanks that's encouraging to see people working on Swift for Android ! Seeing Compose multi-platform in alpha makes me think we should work to have something similar done in Swift thus my question about the UI side of things for wasm or any platform really ^^

1 Like

Any other insight on which UI framework to use with SwiftWasm ? Is Tokamak still the official solution ? Is it still maintained ?

On the UI side, this thread on the Mobile Native Foundation discussion indicates that quite a few teams have invested in Server Driven UI based appraoches over the years.

Personally I think there would be a lot of interest in an open source set of tools for creating, downloading and verifying signed wasm binaries on iOS & Android, that could compliment either SDUI, KMM or a hypothetical swift cross platform UI system. Maybe built on top of GitHub - wasm-signatures/wasmsign2: Implementation of the WebAssembly Modules Signatures.?

Ideally this would be composable so that teams can choose their own WASM interpreter such as wasm3, WasmKit, etc.