Hello everyone,
I’m working on a extension wich require some identification keys.
On the java side, I need those key in the Application.java class so I chose to put the keys in project.xml with <setenv>
and get the key with a template.
On ios, I have to pass those keys from Main.hx, but, I don’t like it because then I’ll have the same keys several time in the project (those in xml and those in main.hx)
So I looked for a way to get what I put in <setenv>
at compile time with macro.
I’ve got something like this :
user’s project.xml
<setenv name="apiKey" value="soijsdfij" />
extensions’s include.xml
<haxedef name="apiKey" value="${apiKey}" />
Macro to get apiKey :
macro public static function getApiKey():Dynamic {
return Context.makeExpr(Compiler.getDefine("apiKey"), Context.currentPos());
}
This works when I build on windows for android,
trace(getApiKey()) returns the apiKey, but, when I build on mac for iOs, I get null :’(
Is this a bug ? Is there any other way to achieve what I want to do ?
I really don’t want to have the same data at several places in the project, if a team member forget to change it in one place this can lead to big time waste, especially on iOs and those 2 weeks validation time…
Thanks you!