Use a custom TensorFlow Lite buildplat_ios

If you're an experienced ML developer and the pre-built TensorFlow Lite library doesn't meet your needs, you can use a custom TensorFlow Lite build with ML Kit. For example, you may want to add custom ops.


  • A working TensorFlow Lite build environment
  • A checkout of 0.1.7 of TensorFlow Lite

You can check out the correct version using Git:

git checkout -b work
git reset --hard tflite-v0.1.7
git cherry-pick f1f1d5172fe5bfeaeb2cf657ffc43ba744187bee

Building the Tensorflow Lite library

  1. Build Tensorflow Lite (with your modifications) following the standard instructions
  2. Build the framework:

The generated framework can be found at tensorflow/contrib/lite/gen/ios_frameworks/

Creating a local pod

  1. Create a directory for your local pod
  2. Run pod lib create TensorFlowLite in the directory you created
  3. Create a Frameworks directory inside the TensorFlowLite directory
  4. Unzip the file generated above
  5. Copy the unzipped tensorflow_lite.framework to TensorFlowLite/Frameworks
  6. Modify the generated TensorFlowLite/TensorFlowLite.podspec to reference the library: do |s|             = 'TensorFlowLite'
      s.version          = '0.1.7' # Version must match.
      s.ios.deployment_target = '9.0'
      # ... make other changes as desired
      internal_pod_root = Pathname.pwd
      s.frameworks = 'Accelerate'
      s.libraries = 'c++'
      s.vendored_frameworks = 'Frameworks/tensorflow_lite.framework'

      s.pod_target_xcconfig = {
        'SWIFT_VERSION' => '4.0',
        'INTERNAL_POD_ROOT' => "#{internal_pod_root}",
        'HEADER_SEARCH_PATHS' => "$(inherited) '${INTERNAL_POD_ROOT}/Frameworks/tensorflow_lite.framework/Headers'",
        'OTHER_LDFLAGS' => "-force_load '${INTERNAL_POD_ROOT}/Frameworks/tensorflow_lite.framework/tensorflow_lite'"

Referencing the custom pod in your project

You can include the custom pod by referencing it directly from your app's Podfile:

pod 'Firebase/MLModelInterpreter'
pod 'TensorFlowLite', :path => 'path/to/your/TensorflowLite'

For other options for managing private pods, see Private Pods in the Cocoapods documentation. Note that the version must exactly match, and you should reference this version when including the pod from your private repository, e.g. pod 'TensorFlowLite', "0.1.7".

Send feedback about...

Need help? Visit our support page.