Haxe Right Tools for IOS and Android App Development

Hello all.
I’m new to the Haxe ecosystem coming from JS, Swift (Mac) and C# (Win). For the last two weeks, I learned Haxe in the CLI on my Mac and I have tried to find the right tools for developing mobile applications. I really like coding in Haxe. It is like Swift and Kotlin just more potent. But also more difficult to get working due to so many choices and the lack of tutorials and up-to-date books. It’s like the rest of the world forgot Haxe and Haxe forgot the world while living and evolving unnoticed.

Problem: So far I have looked at HaxeUI and HashLink but I can’t seem to find out how to get it to work. As far as I can read HaxeUI does not support HashLink.

Q: But how to then use HaxeUI with Haxe?
My vision was to use Haxe as I would Swift for IOS or Kotlin for Android, and I imagined it only was a matter of finding the right tools and libraries.

Q: So now I think it is time to ask for a little help. Does anyone like to share what the best tools for developing native IOS and Android apps in Haxe are, and what the best toolchain is?

My plan was to use:
Haxe HaxeUI and HashLink to C
Fastlane to automate native compilation in Xcode and Android Studio, for building to simulators and for publishing.

It sounded simple enough and logic to me but…Maybe I’m doing it all wrong. Maybe Haxe and a UI has a better way of doing things for native mobile app development.

1 Like

Here is my personal opionion for developing to mobile.

Hashlink do not have a toolchain for mobile development. There is no easy way to compile Android/iOS or write an extension with it ( at example social login ( Facebook, Google, Apple login), in-app payments, crash reports )
The best toolchain ( and the only one) which Haxe has is Hxcpp.
You should use a framework to compile to mobile and for me OpenFL/Lime is the most robust framework for that.

# OpenFL has good support for mobile - Android and iOS - using hxcpp target. There are also many android/ios extensions you can use ( some are outdated , but still good for a base)

# Heaps do not support compiling for mobile (unless you use zyheaps - GitHub - rainyt/zyheaps: Heaps can easily compile Android, IOS, HTML5, MAC, window, etc). Its main support is for consoles and desktop.

# Ceramic can compile to mobile, but I haven’t seen any public ios/android extension available for it.

# About HaxeUI -preferably is to use some kind of framework. Of course you can use html5 target or android one ( not sure how usable it is) or use HaxeUI-Openfl to target mobile devices.
If you choose OpenFL for UI you can also look for FeathersUI ( https://feathersui.com/ )

So to answer your questions:

Q: But how to then use HaxeUI with Haxe?
The best way to choose some of the supported frameworks . For me that is OpenFL . Also check out FethersUI

Q: What the best tools for developing native IOS and Android apps in Haxe?
For me again it is the OpenFL framework ( https://www.openfl.org/ ) . All available extensions are here Haxe Extensions · GitHub

I think the latest version of Lime/OpenFL support Hashlink, but Hxcpp has a better garbage collector,a better toolchain and extensions already available.

2 Likes

Thank you @flashultra for the extensive and very clear answer. I think Haxe can do me a lot of good and I think I’m in. Using OpenFL seems to be a good start while learning the language and later maybe use native UI’s for my apps. I have seen some projects doing that, but that’s not something to start out doing. So as you suggest OpenFL it is.

Thank’s!

Haxe and Kotlin in IntelliJ IDEA

I got to think about a toolchain that combines Haxe and Kotlin in IntelliJ, using Compose Multiplatform for UI. The idea is to compile Haxe to C++ and integrate with Kotlin via cinterop for Kotlin/Native, and by then get to use Compose in IntelliJ while coding in Haxe at the same time in the same IDE. This targets both Android and IOS apps MVVM Haxe backend and Kotlin UI.

Q: Has anyone tried a similar Haxe-Kotlin integration or found a better approach?
Q: Did it work?

If you are going down the OpenFL road I highly recommend FeathersUI. It is robust, well documented, and well supported. Despite its “UI” name it can be a robust application framework and is versatile and highly portable. I started using it by adding its UI components to an existing PureMVC in-browser application. It worked very well for diving in and now if I had to rebuilt everything I would likely consider letting it handle more of the navigation with its Page Navigator and Stack Navigator. It supports many targets out of the box, which saves having to use native UIs.

1 Like

So just to answer the question right off the bat, in my opinion the best choice would be native for mobiles. The primary reason i say this is power consumption (with a secondary emphasis on looking and feeling “right”). All the “game” type frameworks (which i call “draw” frameworks) suffer from the same problem; that is that are constantly “ticking” and chewing up CPU, its not a huge deal on desktops, but its noticeable on laptops and undesirable on mobiles. All of these frameworks are meant to be used for games, not really apps, so they all have this “issue” (kha, nme, ceramic, openfl, all of them) - they are in a tight loop updating constantly even when nothing changes. (I might add that some are certainly better than others)

HaxeUI itself is “backend agnostic”, you can “plugin” any backend framework, be that a “draw” framework or something more native. For example, haxeui-html5 doesnt suffer from these (potential) battery issues as it uses the browser to create dom nodes which are highly efficient and arent constantly redrawing. (haxeui-hxwidgets ofc, also doesnt either)

There is a haxeui-android (native version) in the works, and i have version locally that is very different from the GH version, but its still a WiP effectively, and i feel like its a bad form to release it until i can fully support it - and i know there are issues with it - but it creates 100% native android UIs that simply dont spike at all (CPU wise). Your battery is safe :slight_smile:

Its certainly worth mentioning that haxeui-android just uses haxe jvm target and builds UIs directly from clever java-lib interop (thanks haxe!). So you could build a native android, now, with no deps. iOS is a different story (as usual) but i think hugh has successfully demo’d that you can interop with native libs on iOS via hxcpp.

In short, and in my opinion, anything that is sitting there drawing 60 (or 30, or 15) fps is going to be really bad for UX, its going to eat power like you were running a game (which you effectively are), there are other options out there, in HaxeUI’s case, not full formed just yet. (though directly using hxcpp to interface into native UI libs is certainly what i would consider a “good direction”, which seems like your direction)

Funnily enough, this has come up on the discord quite a bit recently, and 2024 is going to be “the year of the mobile” for HaxeUI as its a target i just dont (personally) care about too much, but a valid one none-the-less.

Not sure if any of that helps at all, but i thought i would weigh in about my direction. :slight_smile:

Cheers,
Ian

Not sure about @lpmathiasendk but I appreciate your educating us @ianharrigan . After writing that I was thinking I should have mentioned that HaxeUI is an excellent choice if you don’t care to use OpenFL. And you have now shown us why!

1 Like

option1) hxjava
for android: use hxjava ( haxe/java ) target to compile your haxe code to android .apk using android tools. ( I WILL RECOMMEND THIS esp. for android)

some additional discussion here

some additional tool here, it is totally old but probably this will give you an idea
https://lib.haxe.org/p/androidhx/


( I do not know about iOS development, but here is a video where someone is telling about developing iOS applications with java.

And

so obviously hxjava can be applied in iOS too)

=================================

option2) using haxe/C++ with

openFl and NME with StablexUI and HaxeUI

haxe foundation is recommending this route, as it is on their mobile development related webpage


some additional libs from here may help you
https://lib.haxe.org/t/android/
https://lib.haxe.org/t/ios

I wouldnt use hxjava - haxe jvm works and, imo, is better (and supercededs it)

This was the case in a very old version of haxeui (like a v1, or maybe even a v0), haxeui now supports multiple backends: https://github.com/haxeui/haxeui-core

There is a really interesting one here: https://lib.haxe.org/p/hx-ios-uikit/