lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> We could add the appropriate conditionals to avoid calling system in
iOS but we don't have access to iOS development platforms.
I would love to help by testing on iOS platforms.

> We could not find official documentation on this issue.

The stack overflow post you mentioned ( is the de facto best reference of the available conditionals. It is up to date and tried and tested in our development.

To see the exact platforms Apple has decided to remove system(…) from, here the relevant section of the stdlib.h from my local (macOS 12.3) SDK:

__swift_unavailable("Use posix_spawn APIs or NSTask instead. (On iOS, process spawning is unavailable.)")
int system(const char *) __DARWIN_ALIAS_C(system);

> If someone can provide trusted and tested code for this that is
current, please post here.

I have tested both of the code snippets mentioned this morning ( and and both work well, however the first one does the if-conditionals better, since it exactly replicates the platforms where system is unavailable. Finally, as a third option, my current local solution to this issue is as following:

#if __APPLE__
#include "TargetConditionals.h"

static int os_execute (lua_State *L) {
  return luaL_error(L, "os_execute not available on iOS");
  lua_pushinteger(L, system(luaL_optstring(L, 1, NULL)));
  return 1;

Thank you very much for your time.

Julian Müller-Huschke