Get OpenFL version at runtime/macro?

Is it possible to get OpenFL version at runtime? Maybe there is some kind of way to get versions of used packages via macro magic?

To see what’s available, first compile your app with whatever settings you’re using. (The app doesn’t have to work, so feel free to comment your code.)

Now you want to find the hxml file used to compile your Haxe code. Go to bin or Export, and open the directory for the platform you’re using. (This may be an extra folder deep. For instance, the windows target builds to bin/windows/cpp, and the neko target builds to bin/mac/neko on a Mac.) From here, open the haxe folder.

You’ll find three hxml files, and it doesn’t matter which one you choose. Inside, look for lines that start with -D and contain an equals sign. These are the values that you can retrieve using Compiler.getDefine().

Since “openfl” is one of these, you can get its version using haxe.macro.Compiler.getDefine("openfl").

Thanks! That is exactly what I was looking for :slight_smile: