Skip to content

Latest commit

 

History

History
49 lines (39 loc) · 1.29 KB

sample-how-to-use-it.md

File metadata and controls

49 lines (39 loc) · 1.29 KB

#How to use vmob

iOS

  1. Write your V module

Be sure to use [export: ] followed by module name

module vex
import math 

[export: vex_absolute_value]
pub fn vex_absolute_value(a f64) f64{
	return math.abs(a)
}

fn init(){
	println("Vex module has been called")
}
  1. Build static library (.a file) targeting iPhone (arm64) ./vmob apple-ios-iphone -s false path/to/module
  2. Build static library (.a file) targeting iOS Simulator (x86_64) ./vmob apple-ios-simulator -s false path/to/module
  3. Combine two targets into universal target ./vmob combine -o modulename-ios path/to/module-arm64.a path/to/module-x86_64.a
  4. Generate header file that you will use as bridge between your library and Xcode ./vmob header-gen -a arm64 -mp vex path/to/module

Xcode:

  1. Open Xcode
  2. Create new folder called your-ios-module-name
  3. Drag and drop your universal modulename-ios.a and .h file
  4. New File -> C -> Enable Bridging Header
    • add line #include "modulename_header.h file
  5. Call method from your Swift code
     override func viewDidLoad() {
        super.viewDidLoad()
        println(vex_absolute_value(-1)) // 1
    }

Have in mind this all this be automated in Xcode build script

Android

Not yet supported