This is the example app of mopro. You can use the following commands to build native bindings for your iOS and/or Android app.
📚 To learn more about mopro, visit: https://zkmopro.org
To set up and build bindings, follow these steps.
- Get published CLI
cargo install mopro-cli- Or get the latest CLI on GitHub
git clone https://github.com/zkmopro/mopro
cd mopro/cli
cargo install --path .Navigate to the Mopro example app directory and initialize setup by running:
mopro initBuild bindings for your project by executing:
mopro buildTo generate templates tailored to your target platform, use:
mopro createFollow the instructions to open the development tools
For iOS:
open ios/MoproApp.xcodeprojFor Android:
open android -a Android\ StudioFor Web:
cd web && yarn && yarn startFor React Native:
Follow the README in the react-native directory. Or zkmopro/react-native-app/README.md
For Flutter:
Follow the README in the flutter directory. Or zkmopro/flutter-app/README.md
After creating templates, you may still need to update the bindings.
mopro build will prompt you to run mopro update to refresh the bindings in each template. You can also run it automatically:
mopro build --auto-updateOr manually:
mopro updateFor mobile native apps (iOS and Android), you can use #[uniffi::export] to define custom functions that will be included in the generated bindings. For example:
#[uniffi::export]
fn mopro_hello_world() -> String {
"Hello, World!".to_string()
}After defining your custom functions, run the standard Mopro commands (mopro build, mopro create, or mopro update) to regenerate and update the bindings for each target platform.
For web (WASM) apps, you can use #[wasm_bindgen] in src/lib.rs to expose custom functions to JavaScript. For example:
#[cfg_attr(
all(feature = "wasm", target_arch = "wasm32"),
wasm_bindgen(js_name = "moproWasmHelloWorld")
)]
pub fn mopro_wasm_hello_world() -> String {
"Hello, World!".to_string()
}After running mopro build, be sure to run mopro update to refresh the bindings in each template. This command automatically finds the appropriate bindings folders and updates them accordingly.
Run tests before building bindings
curl -L https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.13.0/jna-5.13.0.jar -o jna-5.13.0.jar
export CLASSPATH=jna-5.13.0.jar
cargo test