Downloads and caches pre-built TensorFlow Lite native libraries for Android and iOS so Mob apps can ship the TFLite Nx backend without building TFLite from source (Bazel).
Two upstream sources:
- Android —
tensorflow-lite-2.16.1.aarfrom Maven Central (the last release with a packed.aar; 2.17.0 ships.jaronly). Extracted tojni/arm64-v8a/libtensorflowlite_jni.so+headers/tensorflow/lite/c/c_api.hetc. - iOS —
TensorFlowLiteC-2.17.0.tar.gzfromdl.google.com(CocoaPods upstream). Contains three xcframeworks (Core, CoreML, Metal) each withios-arm64device +ios-arm64_x86_64-simulatorslices.
The C API is binary-compatible between these versions — TFLite's
c_api.h surface has been stable since 2.13. Different version pins
per platform reflect upstream packaging differences, not API drift.
Mirrors the MobDev.MLXDownloader pattern: hashed URL + cached
extraction at ~/.mob/cache/tflite-<version>-<target>/, validated
against the expected layout. Reused across projects.
Used by MobDev.NativeBuild when the project enables TFLite via
mix mob.enable tflite. The build template sources TFLITE_DIR from
dir/1 and links the tflite_nif.c NIF against the headers and
framework / .so it provides.
Local-build override
Set MOB_TFLITE_LOCAL_TARBALL_DIR=/path/to/dir to bypass the upstream
download and use locally-fetched tarballs (named exactly as
tarball_name/1 returns). Useful when iterating offline or against
a custom TFLite build.
Summary
Functions
Android TFLite version pin.
Cached TFLite root directory for target. May not exist if ensure/1
hasn't been called.
Ensure the TFLite bundle for target is cached and extracted.
iOS TFLite version pin.
Returns true if the cache directory has the expected layout for the
given target. Public for tests and NativeBuild probing.
Types
Functions
@spec android_version() :: String.t()
Android TFLite version pin.
Cached TFLite root directory for target. May not exist if ensure/1
hasn't been called.
Ensure the TFLite bundle for target is cached and extracted.
Returns {:ok, path} where path is the unpacked root containing the
expected layout (see valid_dir?/2).
@spec ios_version() :: String.t()
iOS TFLite version pin.
Returns true if the cache directory has the expected layout for the
given target. Public for tests and NativeBuild probing.