Setting up UniFFI for iOS, Simulators, and watchOS

Christian Kjær
3 min readJun 25, 2024

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 project
  • capacitor-rs: Bridging code between the Capacitor JS library and our Rust code
  • shared: Our shared code that we might use in appy, and also want to expose in Swift to use in our Widgets or watchOS App
  • mobile: Where we will generate the Swift bindings from via UniFFI, reexporting everything from shared 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…

--

--

Christian Kjær

Founder of codetalk.io and blogging on codethoughts.io 👀 •• Rust/Serverless ❤️ Previously: Director of Eng at Famly 🌱 Built IoT platform at Factbird ☁️