Anyone using Rust for mobile cross-platform dev?

Hello,

I currently develop for Android for a living and I've been interested in going onto iOS at some point. I recently saw the Dropbox presentation on sharing code between Android and iOS using a MVVM architecture and a binding generator called "Djinni", and I'm curious if I can do something similar with Rust. :slight_smile:

Why Rust? I'm a Java developer and I don't have that much experience debugging native crashes and stuff like that, and Rust is interesting in that it gives a way to do native cross-platform development while also providing safety. Performance and tight integration with the platform is important to me, and Rust looks like it would be able to deliver. I could isolate the core code while still using best-practices native tools and languages for each platform's front-end, which is something lacking from many of the professional tools out there.

Is anyone currently doing this? What is the state of the compilers and the tools? Is the language production-ready for mobile development? I checked out the Big Nerd Ranch tutorial on cross-compiling Rust for iOS and it was straightforward to get stuff compiling. However, I'm concerned as both Android and iOS are listed as "Tier 3" platforms in the official Rust intro, and there just doesn't seem to be much in the way of official documentation. I'm worried about running into library bugs, or other snafus that might be obvious to a native developer but not so much to someone coming from Java development, for example stuff like passing the right flags to the compilers to avoid esoteric crashes because I screwed up the ABI calling convention.

My other concern would be tooling and debugging. Although there is less safety with C++ and C, Xcode comes with a bunch of great tools that would let me trace and debug issues directly.

My other alternative would be to wait and see what open-source Swift is going to look like, or just go ahead and build up an entirely new code base for iOS with Swift. That's not entirely unreasonable as I'm going to have to write all-new code for the UI and platform-specific components anyways; on the other hand it also means increasing maintenance costs due to duplication going into the future, and it also means I miss out on learning a new language and putting it into practice. :wink: I'm just not sure where the balance lies with the tradeoffs in place, and if I'm exploring largely uncharted waters and what it means for these platforms to be "Tier 3" and if that's going to change in the future.

2 Likes

perhaps links below will help you:
Example project for building a library for iOS + Android in Rust https://github.com/kennytm/rust-ios-android
by the way,if you are a java developer,google`s j2objc or robovm is more mature

1 Like

Those tools do look interesting, particularly RoboVM! Unfortunately, my Java code is not really in a state where it would be easily reusable. :wink: I'd be rewriting the parts that I want to share, which is why I was interested in Rust as a possible alternative.

It's been 3 years since this post, but Google brought me strait here from an "android rust hello world" search. I find myself today in a somewhat comparable situation as OP back then. I'm starting to learn Rust, loving it, and basically thinking about what to do with it once I finish The Book. I'm considering a small Android app capable of talking to a RESTfull API I already have running on our server here. It would be a small thing, but I'd brag about it as if it was an entire OS written in assembly lol

1 Like