Skip to content
probablycorey edited this page Feb 10, 2011 · 6 revisions

So you want to compile your Lua files to bytecode?

I don't blame you, it makes it harder for people to see your precious codes.

First get a 32-bit version of Lua installed on your Mac

** This will overwrite your local version of Lua, if you don't want to do that look into changing the Lua binary name in the makefile. **

  1. Download the Lua source from http://www.lua.org/download.html

  2. Patch LUA_SOURCE/src/Makefile to make it 32-bit

    # Change this line
    macosx:
    -  	$(MAKE) all MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-lreadline"
    + 	$(MAKE) all MYCFLAGS="-DLUA_USE_LINUX -arch i386" MYLIBS="-arch i386 -lreadline"

    # If you are having trouble compiling this because of 
    # readline, try removing '-lreadline'
  1. Make and install Lua:
    make macosx
    sudo make install
```

Add a Build Phase to your project
---

** This won't work if you are using the wax.framework (That would be easy to do, I'd just like someone else to document it.)**

1. Open your project in Xcode and click ** Project > Edit Active Target **

2. Click the **Build** tab.

3. Make sure the **Configuration:** drop down has **All Configurations** selected.

4. Select **User-Defined Settings** in the **Show:** dropdown. 

5. Add a settings named `WAX_COMPILE_SCRIPTS` and set the value to 1.

6. Build the app and look at the build results... You should see `Wax is using compiled Lua scripts.` in the log.