Exadra37

Exadra37

Elixir Desktop - Can it be used to write SDKs for Android and iOS?

I want to write an SDK for Android and iOS where the core will be written once in a programming language that can be then wrapped by Swift and Kotlin.

I know I can do it in C, and I think it’s possible to do it in Rust, but wondering if Elixir desktop can do it?

Most Liked

dominicletz

dominicletz

Creator of Elixir Desktop

This option is tricky but possible on Android, but it’s impossible on iOS. There is no such thing as stdin/stdout communication on iOS. You can’t in fact ship more than one executable. Everything has to be one big statically linked object file. You can checkout the port of the beam, but in short the system() and spawn_port() commands are not supported on iOS. This is an iOS limitation and intended by apple.

For that reason I went with JSON communication via sockets. But it’s all running in the same iOS process. With some more native plumbing the socket could be replaced with in-process communication with memory buffers which would be more efficient, but I didn’t have enough time for that.

derek-zhou

derek-zhou

I knew the IOS is locked down; I didn’t know it is this locked down. Thanks!

Exadra37

Exadra37

Ping to @dominicletz (the author).


For example the Mozilla foundation uses UniFFI to help with the generation of the bindings to include Rust in their SDKs for Android, iOS and others:

UniFFI is a tool that automatically generates foreign-language bindings targeting Rust libraries.
It fits in the practice of consolidating business logic in a single Rust library while targeting multiple platforms, making it simpler to develop and maintain a cross-platform codebase.
Note that this tool will not help you ship a Rust library to these platforms, but simply not have to write bindings code by hand

I still need to find resources on how to compile to iOS and Android.

dominicletz

dominicletz

Creator of Elixir Desktop

It’s definitely possible, whether it’s advisable in your case I don’t know. You will have to ship the iOS and Android runtimes with your SDK and adjust the Bridge.swift / Bridge.kotlin files to expose your API.

You would not in fact be using the Elixir-desktop library but just the runtimes and your own code to respond to the API calls. The bridge in the mobile sample apps is using socket communication to send and receive messages between native and Elixir. There is no API generation tool and creating one would be a pretty creative task as you need real type information for Kotlin/Swift API that you don’t have in Elixir. So maybe generation from the typespec meta-data?

I recommend you get started by trying to run the android or iOS sample app on your machine. Feel free to PM me on any issues your running into.

dominicletz

dominicletz

Creator of Elixir Desktop

To add to that this is the Elixir-desktop bridge library bridge/bridge.ex at main · elixir-desktop/bridge · GitHub

It’s a simple socket server using JSON for data exchange between native and Elixir. This one is specific to Elixir-desktop and mocks the wxWidgets APIs that are not existing on iOS and Android. For your SDK case you would be able to use the same approach but implement your own Bridge that wraps your APIs.

Where Next?

Popular in Questions Top

JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
pgiesin
This should be a simple problem but I just can’t seem to figure it out. I have a standalone Elixir app that won’t find the database. Dep...
New
Werner
Hi, I’m using Ubuntu 18.04 and after updating to OTP-24.0 yesterday i have this warning when I run “mix local.hex”: 14:57:30.512 [warn] ...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
gonzofish
I’m currently trying to understand how to join three tables using Ecto. All the examples I’ve seen use 2, so maybe I’m just missing somet...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New

Other popular topics Top

TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
mgjohns61585
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement