I've worked on some projects (private and commercial) where embedding Rust into one of those targets was required: iOS, Android, Flutter, macOS, Web. I've played around with a variety of approaches because there exist multiple solutions depending on the platform. Apart from Web/Wasm, where Rust really shines, the next best solution is uniffi by Mozilla, which has quite solid iOS/Android support:<p><a href="https://github.com/mozilla/uniffi-rs" rel="nofollow">https://github.com/mozilla/uniffi-rs</a><p>While this works, the bigger pain (at least on iOS) is that the Rust-Compiler LLVM and Xcode LLVM are not always in sync leading to strange bugs. Also, packaging Rust libraries into a nice XCFramework (or even SPM Module) works, but usually involves hacky shell scripts.<p>The reason why you'd still want to do this is if there's a Rust library that has no equivalent on the Kotlin or Swift side. There're a lot of good crates / libraries for Rust would require an expensive re-implementation in Swift or Kotlin. Also, because Rust doesn't have a garbage collector, it is easier to embed in garbage collected languages like Kotlin without running into situations where the two garbage collectors don't agree.
I don't have a need for this personally, but having been forced to deal with some Java build nightmares like PyLucene's JCC[1], I respect the hell out of these guys for figuring it out and actually documenting it with a working example for others to take advantage of.<p>[1]: <a href="https://lucene.apache.org/pylucene/jcc/" rel="nofollow">https://lucene.apache.org/pylucene/jcc/</a>
<i>"Since I have experience in cross-compiling and building automation, I often choose Rust as my primary programming language."</i> - hmmm, not sure I see how the second follows from the first?<p><i>"In addition, Rust is still a relatively new language, and utilizing any technology from the previous decade is setting you up to fail."</i> - er, no? Or at least you should consider the thought that using a technology that isn't established yet and might be abandoned could also set you up for failure? Not saying that Rust is in danger of that, but...<p><i>"Sometimes, following the hype train is the quickest route to success."</i> - ok, I'm not sure I want to read this article anymore. Or is my irony detector malfunctioning?