Fails to build on iOS: 'system' is unavailable: not available on iOS

58 views
Skip to first unread message

Rodrigo Delduca

unread,
May 20, 2025, 6:57:27 AMMay 20
to lua-l
The package lua/5.4.6 fails to build on iOS due to the use of the system() function in src/loslib.c, which is explicitly marked unavailable on iOS:

```
error: 'system' is unavailable: not available on iOS
  stat = l_system(cmd); 
```

This is due to the default macro:

```
#define l_system(cmd) system(cmd)
```

On iOS, system() is unavailable because of sandboxing restrictions.


Proposed Solution

Modify loslib.c to disable or override l_system(cmd) when building for iOS. For example:

```
#ifdef __APPLE__
#include <TargetConditionals.h>
#if TARGET_OS_IPHONE
#define l_system(cmd) (-1)
#else
#define l_system(cmd) system(cmd)
#endif
#else
#define l_system(cmd) system(cmd)
#endif
```

Logs

```
[ 66%] Building C object CMakeFiles/lua.dir/src/src/lparser.c.o
/Users/runner/.conan2/p/b/lua8c2871f3f4385/b/src/src/loslib.c:146:10: error: 'system' is unavailable: not available on iOS
  stat = l_system(cmd);
         ^
/Users/runner/.conan2/p/b/lua8c2871f3f4385/b/src/src/loslib.c:137:23: note: expanded from macro 'l_system'
#define l_system(cmd)   system(cmd)  /* default definition */
                        ^
/Applications/Xcode_15.4.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.5.sdk/usr/include/stdlib.h:184:6: note: 'system' has been explicitly marked unavailable here
int      system(const char *) __DARWIN_ALIAS_C(system);
         ^
1 error generated.
make[2]: *** [CMakeFiles/lua.dir/src/src/loslib.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/lua.dir/all] Error 2
make: *** [all] Error 2

lua/5.4.6: ERROR:
Package '8a9d8d5676921ce70bce09204c3082019cf26832' build failed
lua/5.4.6: WARN: Build folder /Users/runner/.conan2/p/b/lua8c2871f3f4385/b/build/Release
ERROR: lua/5.4.6: Error in build() method, line 80
cmake.build()
ConanException: Error 2 while executing
```

Luiz Henrique de Figueiredo

unread,
May 20, 2025, 7:01:27 AMMay 20
to lu...@googlegroups.com
> The package lua/5.4.6 fails to build on iOS due to the use of the system() function in src/loslib.c, which is explicitly marked unavailable on iOS:

"make ios" or "cc -DLUA_USE_IOS" should work.

Rodrigo Delduca

unread,
May 20, 2025, 12:43:50 PMMay 20
to lua-l
It worked, thank you!
Reply all
Reply to author
Forward
0 new messages