Pod::Spec.newdo|s|s.name='TensorFlowLite's.version='0.1.7'# Version must match.s.ios.deployment_target='9.0'# ... make other changes as desiredinternal_pod_root=Pathname.pwds.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'"}end
在您的项目中引用自定义 pod
要添加自定义 pod,只需直接从应用的 Podfile 中引用它即可:
pod 'Firebase/MLModelInterpreter'
pod 'TensorFlowLite', :path => 'path/to/your/TensorflowLite'
如需了解有关管理专用 pod 的其他选项,请参阅 Cocoapods 文档中的专用 pod。请注意,版本必须完全匹配,并且当您从专用代码库中添加 pod(例如 pod 'TensorFlowLite', "1.10.1")时,应该引用此版本。
[null,null,["最后更新时间 (UTC):2025-08-27。"],[],[],null,["\u003cbr /\u003e\n\nIf you're an experienced ML developer and the pre-built TensorFlow Lite\nlibrary doesn't meet your needs, you can use a custom\n[TensorFlow Lite](//www.tensorflow.org/mobile/tflite/) build with ML Kit. For\nexample, you may want to add custom ops.\n\nPrerequisites\n\n- A working [TensorFlow Lite](//github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/README.md#building-tensorflow-lite-and-the-demo-app-from-source) build environment\n- A checkout of TensorFlow Lite 1.10.1\n\nYou can check out the correct version using Git: \n\n git checkout -b work\n git reset --hard tflite-v1.10.1\n git cherry-pick 4dcfddc5d12018a5a0fdca652b9221ed95e9eb23\n\nBuilding the Tensorflow Lite library\n\n1. Build Tensorflow Lite (with your modifications) following the [standard instructions](//github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/g3doc/guide/build_ios.md)\n2. Build the framework:\n\n```\ntensorflow/lite/lib_package/create_ios_frameworks.sh\n```\n\nThe generated framework can be found at `tensorflow/lite/gen/ios_frameworks/tensorflow_lite.framework.zip`\n| **Note:** There have been [build issues\n| reported](https://github.com/tensorflow/tensorflow/issues/18356) with Xcode 9.3\n\nCreating a local pod\n\n1. Create a directory for your local pod\n2. Run `pod lib create TensorFlowLite` in the directory you created\n3. Create a `Frameworks` directory inside the `TensorFlowLite` directory\n4. Unzip the `tensorflow_lite.framework.zip` file generated above\n5. Copy the unzipped `tensorflow_lite.framework` to `TensorFlowLite/Frameworks`\n6. Modify the generated `TensorFlowLite/TensorFlowLite.podspec` to reference the library:\n\n Pod::Spec.new do |s|\n s.name = 'TensorFlowLite'\n s.version = '0.1.7' # Version must match.\n s.ios.deployment_target = '9.0'\n \n # ... make other changes as desired\n \n internal_pod_root = Pathname.pwd\n s.frameworks = 'Accelerate'\n s.libraries = 'c++'\n s.vendored_frameworks = 'Frameworks/tensorflow_lite.framework'\n\n s.pod_target_xcconfig = {\n 'SWIFT_VERSION' =\u003e '4.0',\n 'INTERNAL_POD_ROOT' =\u003e \"#{internal_pod_root}\",\n 'HEADER_SEARCH_PATHS' =\u003e \"$(inherited) '${INTERNAL_POD_ROOT}/Frameworks/tensorflow_lite.framework/Headers'\",\n 'OTHER_LDFLAGS' =\u003e \"-force_load '${INTERNAL_POD_ROOT}/Frameworks/tensorflow_lite.framework/tensorflow_lite'\"\n }\n end\n\nReferencing the custom pod in your project\n\nYou can include the custom pod by referencing it directly from your app's\n`Podfile`: \n\n pod 'Firebase/MLModelInterpreter'\n pod 'TensorFlowLite', :path =\u003e 'path/to/your/TensorflowLite'\n\nFor other options for managing private pods, see\n[Private Pods](https://guides.cocoapods.org/making/private-cocoapods.html) in\nthe Cocoapods documentation. Note that the version must exactly match, and you\nshould reference this version when including the pod from your\nprivate repository, e.g. `pod 'TensorFlowLite', \"1.10.1\"`."]]