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

**URL:** <https://forums.solar2d.com/t/ios-how-can-i-pass-launch-args-to-main-lua/151079>\
**Category:** Native builds\
**Created:** [January 30, 2020, 4:29am UTC](https://forums.solar2d.com/t/ios-how-can-i-pass-launch-args-to-main-lua/151079 "2020-01-30T04:29:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![otkmember](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/o/c5a1d2/32.png) [@otkmember](https://forums.solar2d.com/u/otkmember)\
**Post date:** [January 30, 2020, 4:29am UTC](https://forums.solar2d.com/t/ios-how-can-i-pass-launch-args-to-main-lua/151079/1 "2020-01-30T04:29:54Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![XeduR](https://forums.solar2d.com/user_avatar/forums.solar2d.com/xedur/32/256_2.png) [@XeduR](https://forums.solar2d.com/u/XeduR)\
**Post date:** [January 31, 2020, 6:16am UTC](https://forums.solar2d.com/t/ios-how-can-i-pass-launch-args-to-main-lua/151079/2 "2020-01-31T06:16:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![otkmember](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/o/c5a1d2/32.png) [@otkmember](https://forums.solar2d.com/u/otkmember)\
**Post date:** [January 31, 2020, 8:11am UTC](https://forums.solar2d.com/t/ios-how-can-i-pass-launch-args-to-main-lua/151079/3 "2020-01-31T08:11:10Z")

</div>

> [@XeduR](#):
>
> 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 = ...
> 
> ```

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.

---

<div class="post-metadata">

**Author:** ![XeduR](https://forums.solar2d.com/user_avatar/forums.solar2d.com/xedur/32/256_2.png) [@XeduR](https://forums.solar2d.com/u/XeduR)\
**Post date:** [January 31, 2020, 8:28am UTC](https://forums.solar2d.com/t/ios-how-can-i-pass-launch-args-to-main-lua/151079/4 "2020-01-31T08:28:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![otkmember](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/o/c5a1d2/32.png) [@otkmember](https://forums.solar2d.com/u/otkmember)\
**Post date:** [February 2, 2020, 1:34pm UTC](https://forums.solar2d.com/t/ios-how-can-i-pass-launch-args-to-main-lua/151079/5 "2020-02-02T13:34:21Z")

</div>

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

here is piece of my code&nbsp;

```
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.
