/ios-app-rs

Primary LanguageRustMIT LicenseMIT

Proof of concept: iOS app written in pure Rust

To Run

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's selector in pure Rust

Notes

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 via objc-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 with iced and interact with iOS with objc-derive