ApplicationMain.hx

What I want to achieve

I’m writing Haxe with VSCode.

It seems that even if you add the write attribute and change ApplicationMain.hx,
it is designed so that the system will overwrite (restore) it.

So I’d like to ask for your advice.

If there is a setting that will prevent the system from automatically restoring ApplicationMain.hx even if it is edited,
I would really appreciate your advice.

What I’ve tried

I edited it with chmod 666 ApplicationMain.hx (default location).

However, the system immediately corrects the edited contents,

if I move ApplicationMain.hx to a different folder,
it becomes editable,
but that is meaningless from a development perspective,
so I want to be able to freely edit ApplicationMain.hx in the default location
while organically connecting it to other sources.

I’m using VSCode1.97.0 on Ubuntu 24 LTS arm.

I think I am correct to assume you use lime / openfl / flixel frameworks. I also believe that lime command is what generates ApplicationMain.hx in your export / output folder. it will do so on every compile / build.
I usually don’t do a lot of lime / openfl work, but I think anything in export / output folder has to be considered “readonly”, since lime will re-generate it’s contents with every compilation run.
so whatever you need to do by editing ApplicationMain.hx you need to find a different solution, because most likely you are doing something wrong or at least not in the spirit of the frameworks you’re using.

e.g. there might be a template file from which ApplicationMain.hx is generated and you might be able to change that without editing or forking the entire framework, but that’s probably a question for openfl or flixel community people.

1 Like

Thank you for your response, ablum.

Here’s the translation:

“Your perspective was very helpful. It made me reconsider a lot of things as well.”

@ablum is correct.

You can find ApplicationMain.hx in {haxelib}/lime/{version}/templates/haxe. You can just duplicate that file in your own source code logic, ie. copy the file to Templates\haxe\ApplicationMain.hx in the root of your code, then add <template path="Templates"/> in your project.xml. After that you can freely edit it, the compiler will pick the custom one up instead of the global one.

2 Likes

Sure! Here’s the English translation:

@Igazine, thank you so much for providing such valuable information. Thanks to your specific and practical advice, I now have a much clearer path forward.”

Let me know if you’d like any adjustments!

1 Like

Here is a sample project that I created to demonstrate how to use a custom ApplicationMain.hx template with OpenFL:

1 Like

Thank you for your response, joshtynjala.