iOS - How can i pass launch args to main.lua?

The docs says that “willLoadMain” method execute before main.lua will be called.

so, i want to pass some data as an argument table, like a product version, sandbox or debug bool values, etc.

is the any way can i perform it?

or, maybe i could set table in _G from this point? its fine too.

If I remember correctly, all you need to do to get launch arguments is to put the following line of code in your main.lua.

local launchArgs = ...

I think that the only way you can pass those launchArgs was via URLs or notifications, but it’s been such a long while that things may have changed.

this part is familiar to me, the question is how to put the lua table in those args.

maybe it has some function like Corona::Lua::DispatchRuntimeEvent(L, …); which i can call from AppCoronaDelegate file.

it probably must have one.

I am probably misunderstanding what you mean, but you can add tables to it in main.lua via

local launchArgs = { ... } launchArgs.myTable = {}

If you want to include some extra data to the launchArgs before main.lua, then you’ll probably need to dig into Corona source. As far as I remember, only way to get anything to launchArgs is by starting a Corona app via notifications or via URL.

so, for now i find out how to set table in _G and use it.

here is piece of my code 

lua\_newtable(L); lua\_setglobal(L, "\_CONST"); lua\_getfield(L, LUA\_GLOBALSINDEX, "\_CONST"); for ( NSString \*key in constants ){ if ( [constants[key] isKindOfClass:[NSString class]] ){ const char \*var = [constants[key] UTF8String]; lua\_pushstring(L, var); lua\_setfield(L, -2, [key UTF8String] ); } if ( [constants[key] isKindOfClass:[NSNumber class]] ){ lua\_pushnumber(L, [constants[key] intValue]); lua\_setfield(L, -2, [key UTF8String] ); } } lua\_pushboolean(L, (isProduction) ? 1 : 0 ); lua\_setfield(L, -2, "PRODUCTION" ); lua\_pop(L, 1);

but anyway, if the solution with launch args will appear, please, let me know.