8

I have some function module written in Objective-c, could i wrap the objective-C by C++, then integrate C/C++ code with Lua using toLua++, then using the lua code in Corona? Could i do that? It seems impossible...

timestee
  • 1,086
  • 12
  • 36

2 Answers2

2

Corona doesn't allow extending with native code (yet) It is in their roadmaps, and it is supposed to be implemented in coming months

SatheeshJM
  • 3,575
  • 8
  • 37
  • 60
1

you could make a shared library, then just require it into your code.

e.g. create mylibrary.so

then in lua

require("mylibrary")

lua will look for it in your LUA_PATH.

There are a few things I'm not sure of in corona - if it will load a shared library and you can use toLUa++. It will work fine in normal lua. You might have problems with bindings in the shared library to Cocoa - not sure, not something I've tried. I've built a .dll in windows and it worked fine - again not in corona.

Here's how to build a shared library

It seems like corona will do it - have a look here

this could be the stopper though - no shared libraries on iOS

hth

Community
  • 1
  • 1
daven11
  • 2,905
  • 3
  • 26
  • 43
  • 1
    But the key problem is IN CORONA. -_-! – timestee Mar 21 '12 at 01:59
  • yah but corona is lua with some libraries as far as I understand. The kicker is that you can't have shared libraries on iOS, unless someones figured out a hack. You could conceivably make your own corona shell and statically link your library, this would be hard :-( – daven11 Mar 21 '12 at 09:36
  • 1
    @daven11: [Not all parts of Lua are included.](http://developer.anscamobile.com/content/changes-lua). `require` is preprocessed when you "build", I believe (with Corona, you have to submit your code to their servers to get back a working app). – Mud May 22 '12 at 15:55