Proof of concept: iOS app written in pure Rust
- Install cargo bundle
- Install cargo make
- Start an iOS simulator
cargo make run_ios_sim
The heavy lifting is done by objc-derive.
objc-derive
is a proc macro crate to help:
- Exposing
objc
objects/methods to Rust - Implementing
objc
'sselector
in pure Rust
Recently I looked into how to use Rust to write iOS apps. Most articles describe the hybrid approach of using Rust via FFI, where you use Rust for the core logic and Swift/ObjC/Flutter for the UI. Using 2 languages + FFI can be clumsy and error prone, so I was looking for writing the whole app in Rust.
A few things I learned along the way:
- The closest thing I found is cacao, which has a very preliminary iOS support. Proved defintely we can write iOS apps with Rust only though.
- Based on
cacao
code, I created objc-derive to help with exposing UIKit to Rust. This repo is an example of interacting with UIKit viaobjc-derive
. - Although it works, UIKit in Rust is super verbose.
- iced runs, but kinda buggy with iOS. I saw some intermittent crashes in real devices. It looks like something
iced
+objc-derive
is an interesting combo. You can write the UI withiced
and interact with iOS withobjc-derive