一、下載Wax
下載:http://github.com/probablycorey/wax
將壓縮包解壓。
二、創(chuàng)建wax項目
新建Single View Application項目WaxTest。
打開Finder,在項目目錄WaxTest下新建一個文件夾wax,將wax解壓縮目錄中的bin和lib目錄拷貝到其中,然后將lib目錄中的extentions/SQLite目錄和extentions/xml目錄刪除。
將解壓縮目錄中的xcode-template/scripts和xcode-template/Classes目錄拷貝到wax目錄。
最終的WaxTest目錄如下所示:

回到Xcdoe,在Project Explorer中,使用Add Files…功能將wax、Classes、scripts三個文件夾添加到項目中:

打開Target的Build Phases,使用右下角Add Build Phases的AddRun Script功能增加一個Run Script:

將Shell欄的“/bin/sh”修改為“/bin/zsh”。
將文本框中的“Type a script or drag …”文字刪除,然后從projectexplorer中將wax/lib/build-scripts/copy-scripts.sh文件拖進(jìn)文本框中:

打開Build Phases的Copy Bundle Resources欄,搜索.lua,將所有的*.lua文件從中刪除。
打開main.m,將內(nèi)容修改為:
#import <UIKit/UIKit.h>
#import "wax.h"
#import "wax_http.h"
#import "wax_json.h"
#import "wax_filesystem.h"
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool =[[NSAutoreleasePoolalloc] init];
wax_start("AppDelegate.lua", luaopen_wax_http,luaopen_wax_json, luaopen_wax_filesystem, nil);
int retVal = UIApplicationMain(argc, argv, nil,@"AppDelegate");
[pool release];
return retVal;
}
將項目中的AppDelegate.m、AppDelegate.h、ViewController.m、ViewController.h、ViewController.xib文件刪除。
編譯,出現(xiàn)許多“no previous prototype for function”警告。
打開Target->Build Settings,搜索prototype,將MissingFunction ProtoTypes改為No,警告消除。
Run,模擬器窗口中出現(xiàn)“Hello Lua!”字樣。wax安裝成功。