1# TensorFlow Lite for Swift 2 3[TensorFlow Lite](https://www.tensorflow.org/lite/) is TensorFlow's lightweight 4solution for Swift developers. It enables low-latency inference of on-device 5machine learning models with a small binary size and fast performance supporting 6hardware acceleration. 7 8## Build TensorFlow with iOS support 9 10To build the Swift TensorFlow Lite library on Apple platforms, 11[install from source](https://www.tensorflow.org/install/source#setup_for_linux_and_macos) 12or [clone the GitHub repo](https://github.com/tensorflow/tensorflow). 13Then, configure TensorFlow by navigating to the root directory and executing the 14`configure.py` script: 15 16```shell 17python configure.py 18``` 19 20Follow the prompts and when asked to build TensorFlow with iOS support, enter `y`. 21 22### CocoaPods developers 23 24Add the TensorFlow Lite pod to your `Podfile`: 25 26```ruby 27pod 'TensorFlowLiteSwift' 28``` 29 30Then, run `pod install`. 31 32In your Swift files, import the module: 33 34```swift 35import TensorFlowLite 36``` 37 38### Bazel developers 39 40In your `BUILD` file, add the `TensorFlowLite` dependency to your target: 41 42```python 43swift_library( 44 deps = [ 45 "//tensorflow/lite/swift:TensorFlowLite", 46 ], 47) 48``` 49 50In your Swift files, import the module: 51 52```swift 53import TensorFlowLite 54``` 55 56Build the `TensorFlowLite` Swift library target: 57 58```shell 59bazel build tensorflow/lite/swift:TensorFlowLite 60``` 61 62Build the `Tests` target: 63 64```shell 65bazel test tensorflow/lite/swift:Tests --swiftcopt=-enable-testing 66``` 67 68Note: `--swiftcopt=-enable-testing` is required for optimized builds (`-c opt`). 69 70#### Generate the Xcode project using Tulsi 71 72Open the `//tensorflow/lite/swift/TensorFlowLite.tulsiproj` using 73the [TulsiApp](https://github.com/bazelbuild/tulsi) 74or by running the 75[`generate_xcodeproj.sh`](https://github.com/bazelbuild/tulsi/blob/master/src/tools/generate_xcodeproj.sh) 76script from the root `tensorflow` directory: 77 78```shell 79generate_xcodeproj.sh --genconfig tensorflow/lite/swift/TensorFlowLite.tulsiproj:TensorFlowLite --outputfolder ~/path/to/generated/TensorFlowLite.xcodeproj 80``` 81