Skip to content
junzhan.yzw edited this page Nov 5, 2015 · 8 revisions

Install Wax

Use Cocoapods

  • Use git tag. Add pod 'wax', :git=>'[email protected]:alibaba/wax.git', :tag=>'1.1.0'to your Podfile
  • Use git commit. Add pod 'wax', :git=>'[email protected]:alibaba/wax.git', :commit=>'5c762ad' to your Podfile
  • Use local path. Add pod 'wax', :git=>'[email protected]:alibaba/wax.git', :path=>'/User/junzhan/wax' to your Podfile
  • Don't know Cocoapods? Just google it!
  • See sample in examples/InstallationExample/InstallWithCocoaPods

Add source manually

  • Add lib directory of these files to your project in accordance with the rules.
'lib/*.{h,m}', 
'lib/adaptation/*.{h,m}',
'lib/lua/*.{h,m,c}', 
'lib/extensions/block/*.{h,m}', 
'lib/extensions/ivar/*.{h,m}',
'lib/extensions/capi/**/*.{h,m,c}', 

If you need to use more extensions in Lua, you can add them to your project.

'lib/extensions/CGAffine/*.{h,m}',
'lib/extensions/CGContext/*.{h,m}',
'lib/extensions/filesystem/*.{h,m}' ,
'lib/extensions/HTTP/*.{h,m}',
'lib/extensions/json/**/*.{h,m,c}'
'lib/extensions/SQLite/**/*.{h,m,c}'
'lib/extensions/xml/**/*.{h,m,c}'

If you want to use SQLite, you need add libsqlite3 to Build Phases->Link Binary With Libraries.
If you want to use xml, you need add libxml2 to Build Phases->Link Binary With Libraries and add ${SDKROOT}/usr/include/libxml2 to Build settings->Head Search Path

  • Add -fno-objc-arc to Compiler Flags in TARGETS->Build Phases->Compile Sources for these files.
  • See sample in examples/InstallationExample/InstallWithSource

Use static framework

  • Open your terminal and run cd WAX_ROOT/tools/Framework
  • Then run rake package, wax will be compiled
  • The production is in WAX_ROOT/framework/wax.framework directory
  • Add wax.framework to your project
  • Add the path of wax.framework to Build Settings-> Framework Search Paths.(you'd better use relative directory)
  • Use head file like #import <wax/wax.h>
  • See sample in examples/InstallationExample/InstallWithStaticFramework

Start using wax

    #import "wax.h" // or #import <wax/wax.h>
   wax_start("init.lua", nil);
   // To add wax with extensions, use this line instead
   // #import "wax/wax_http.h"
   // #import "wax/wax_json.h"
   // #import "wax/wax_filesystem.h"
   // wax_start("init.lua", luaopen_wax_http, luaopen_wax_json, luaopen_wax_filesystem, nil);
   
   wax_runLuaString("print('hello wax')");

Attention

  • wax_start should be called before you using any wax's API.
  • wax_start should be called in main thread.
  • wax_start should be called only once.
Clone this wiki locally