- 0.1.0 and develop220.127.116.11.04.2
- 0.1.0 and developiOSmacOS(Intel)macOS(ARM)LinuxtvOSwatchOS
This repo contains build scripts to compile Tesseract and it's dependencies for Apple platforms to be distributed as a Swift package. It's primary goal is to aid in migrating SwiftyTesseract to be consumable as a Swift Package Manager dependency. If you're looking for looking for a quick way to get started with using Tesseract in your Apple platform application without the rough edges of memory management and dealing with C interop, then you should start with SwiftyTesseract.
Add libtesseract as a Swift Package Dependency
// Package.swift // swift-tools-version:5.3 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "AwesomePackage", platforms: [ // These are the minimum versions libtesseract supports .macOS(.v10_13), .iOS(.v11), ], products: [ .library( name: "AwesomePackage", targets: ["AwesomePackage"] ), ], dependencies: [ .package(url: "https://github.com/SwiftyTesseract/libtesseract.git", from: "0.1.0") ], targets: [ .target( name: "AwesomePackage", dependencies: ["libtesseract"], linkerSettings: [.linkedLibrary("z"), .linkedLibrary("c++")] ), ] ) // AwesomePackage.swift import libtesseract
You must link against the following libraries:
This can be done in an Xcode-based project by adding these in Build Phases -> Link Binary with Libaries
In a Swift Package Manager project, this can be achieved by adding the following to your target
// See Package.swift example above for full context targets: [ .target( name: "AwesomePackage", dependencies: ["libtesseract"], linkerSettings: [.linkedLibrary("z"), .linkedLibrary("c++")] ), ]
See SwiftyTesseract's Additonal Configuration notes on considerations for including language training data files.
If you want to build libtesseract from source, you need
pkg-config installed on your machine. These can be installed via homebrew:
brew install automake pkg-config
libtesseract disributes the following dependencies in binary form: