freedomlayer / offset_mobile

Offset mobile application
https://www.offsetcredit.org
GNU Affero General Public License v3.0
9 stars 1 forks source link

iOS Plans #13

Closed bltavares closed 4 years ago

bltavares commented 4 years ago

Hi there folks, congrats on the release of the app!

This is not an issue in itself - it's more to share some ideas on how to allow Offset Mobile to reach iOS - from a fellow developer. I have not found your email address so I'm sharing things here.

I'm an Android user myself (I don't even have an Apple device myself!), and I'm also looking forward making Flutter Apps with Rust core, in order to make the core widespread. That means not only shipping things for Android and iOS, but even taking a look at Desktop.

I've noticed that the mobile app use using a internal binary to execute a server, which is them used by the UI using HTTP. That was my plan also for my first attempt, until a friend shared that "iOS does not allow exec syscalls on apps. Everything has to be linked into the app".

So, if you go to the path of shipping a sibling binary with the app, it would not work with iOS devices :/ I've been following up how Flutter is starting to support FFI, and I've give it a try on two proof-of-concept attemtps of shipping a Rust core in a Flutter App.

It works already! ~with some caveats~. I could create a new FFI layer on Rust, that do exactly the same as the binary would do and spawn a background thread. So the background service would start, but without any exec hehe

For Android, I use cross to compile to the correct Arch and copy the pre-compiled libs to the magic jniLibs folder and that is shipped with the apk. For iOS, the linking process is a little bit more finicky, and after generating a pre-compile file with cargo-lipo and messing with how Cocoapod links file, I could use Dart -> Rust function calls and even "spawn a service" using Dart async.

The same strategy for a background services with HTTP should work, but with a cross-platform initialization process :)

I wish the best for the project and I expect, hopefully, to have helped a bit when considering bringing the project to iOS.

Kind regards and good luck!

realcr commented 4 years ago

@bltavares : I really appreciate the time you took to do this research. It is really helpful. I was wondering the same myself, and somehow had the feeling that the exec binary approach will not work on ios. I still don't take this as the final conclusion. Maybe with some more determination we can make it work (: If not, we might have to go the FFI route.

As you pointed out, the binary run by Offset as the application core is "stcompact". The plan was to use this same binary for all platforms, maybe even for desktop.

I expect some breaking design changes to Offset in the near future, so it might be better to do those changes before making it work on ios. I don't own any Apple device, so I will definitely seek some help when I start doing this.

Regarding my email address, it is real (at) freedomlayer. You can also find it at the contact page from the main Offset website. Always happy to get a message from you.

bltavares commented 4 years ago

I also find the shipping a sibling binary to be an easier distribution strategy and fits better with my mental model. If you find a way to do that on iOS (without jailbreaking) I would love to know so I can also do the same on my projects :)

Since this is not an issue itself, I'll be closing it to not clutter the Issues counter on github.