Setting up UniFFI for iOS, Simulators, and watchOS
Not a Medium member? Read the post here for free.
This is a part of the post:
There are some great resources out there on UniFFI already such as this post, but it doesn’t cover watchOS, so let’s take a quick tour through what I’ve set up in the example repository https://github.com/Tehnix/template-mobile-wasm.
We’ve set up four crates:
appy
: Our Leptos App, Capacitor, and the XCode projectcapacitor-rs
: Bridging code between the Capacitor JS library and our Rust codeshared
: Our shared code that we might use inappy
, and also want to expose in Swift to use in our Widgets or watchOS Appmobile
: Where we will generate the Swift bindings from via UniFFI, reexporting everything fromshared
that’s made available to UniFFI via the macros
I won’t go over the details to get these to play nicely with Cargo and Workspaces, check out the repository for that. Let’s instead focus on a simplified version of what mobile
does (the rest assumes you’re in the mobile/
directory).
💡 Looking for Android support? This is already added in the template repository above. Otherwise…