Exadra37
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?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Latest in /Elixir Desktop
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
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:
I still need to find resources on how to compile to iOS and Android.
dominicletz
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
To add to that this is the Elixir-desktop bridge library bridge/lib/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.
Exadra37
My use case is to build an SDK that will be used to talk with the backend (with added security) and to manage some functionality that will be common to both Android and iOS. To be clear I will not need to do UI stuff.
derek-zhou
If you are not going to do any UI stuff in elixir, then you can just make a headless binary that is controlled by stdin/stdout from the outside. The binary can be distributed inside your mobile app.
Exadra37
You mean I can write the code in Elixir and compile it to native Android and iOS?
Being controlled from the outside, means to maintain complexity in both Swift and Kotlin wrappers, or am I misunderstanding something?
Bear in mind that I am a newbie in terms of mobile app development.
derek-zhou
This is not something I have done either. But to use elixir in any way on the mobile platform, binary generation must be a prerequisite?
On the elixir side it is just port, possibly with a json interface. On the other side, you would need to wrap the port interface in the native language. Some part of it could be automatic code generation based on a spec or something.
Exadra37
I think so.
Wouldn’t be the use of Android and iOS FFI a better option?
derek-zhou
Maybe; however, then you need to link them together; which can be tricky. Whereas with port, it would be quite mechanic to implement and easier to test. True, you pay the cost of serialization and head of line blocking, but if absolute speed is the goal you wouldn’t want to do it in elixir anyway.
dominicletz
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.
erts/emulator/beam/io.c
5a67b2837