Guide

Getting started

You need the platform SDKs you already use for app development: the Android SDK (with a platform such as android-36) and/or Xcode on macOS. The tool never downloads SDK components.

1. Install

The CLI is published as a Dart package and as a prebuilt binary. Current release: 0.1.0-beta.1 (beta).

FromCommandNeeds
pub.devdart pub global activate native_api_bindgenDart 3.9+ (Flutter's Dart works)
Homebrewbrew install lkrjangid1/tap/native-api-bindgenmacOS (arm64, x64) or Linux (x64, arm64)
Sourcedart pub global activate --source path packages/native_api_clia clone of the repository
native-api-bindgen --version
native-api-bindgen doctor

doctor reports the Android SDK, platforms, JDK, Flutter, Xcode, iOS SDK and libclang it finds.

2. Configure

native-api-bindgen init   # writes native_api_bindgen.yaml with safe defaults
platform:
  android:
    platform: "36"
    minApi: 24                  # newer APIs get runtime guards
    entries: [android.content.Intent, android.net.Uri]
    depth: 0
  ios:
    minVersion: "15.0"
    frameworks: [Foundation, UIKit]
    classes: [UIDevice, UIView]
output:
  dir: lib/src/generated
distribution:
  generatedArtifacts: local-only

Generating a whole SDK is never implicit: select entry types, classes, packages or frameworks.

3. Generate

CommandOutput
generate flutterDart over package:jni (Android)
generate iosDart over package:objective_c (+ Swift adapters if configured)
generate react-nativeTypeScript + C++/Objective-C++ runtime library for every configured platform
coverage, why-skipped, explainwhat was generated, what was not, and why
Terminal running native-api-bindgen doctor, generate and coverage in an example project.

4. Add the runtime

Flutter: add the runtimes from pub.dev next to package:jni (Android) and package:objective_c (iOS):

dependencies:
  jni: ^1.0.3
  jni_flutter: ^1.0.3            # Android: application Context / Activity
  objective_c: 9.5.0             # iOS
  ffi: ^2.1.3                    # iOS
  native_api_runtime: ^0.1.0-beta.1
  native_api_ui: ^0.1.0-beta.1   # optional: show native views

React Native: the generated library embeds the runtime, so nothing else is required. Apps that prefer a dependency can use the npm package:

npm install native-api-bindgen-runtime@beta

5. Use

Import the generated library. Complete, tested apps live in examples/: flutter/android_slice, flutter/ios_slice and react-native/slice.

Next: how it works, Flutter, React Native.