Tools : <setenv> <env> <haxedef> don't work the same on mac and windows

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!

iOS and Android are complicated targets to build. It’s frustrating. This sounds like we need to write the contents of the project.environment map into the makefile used for iOS

Ok.

Well I solved my problem with a simple macro :

That’s even better than what I intended to do first as I can have a compile error if i forget to add the <setenv> needed by the extension in the project.xml .

Thanks.