libtesseract

0.2.0

SwiftyTesseract/libtesseract

What's New

0.2.0

2021-03-07T08:48:11Z

Adds support for macOS arm64

libtesseract

Swift Tools Version Badge ios platform badge catalyst platform badge macOS platform badge Deliver

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.

Installation

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.2.0")
  ],
  targets: [
    .target(
      name: "AwesomePackage",
      dependencies: ["libtesseract"],
      linkerSettings: [.linkedLibrary("z"), .linkedLibrary("c++")]
    ),
  ]
)

// AwesomePackage.swift
import libtesseract

Additional Required Configuration

You must link against the following libraries:

  • libc++
  • libz

This can be done in an Xcode-based project by adding these in Build Phases -> Link Binary with Libaries screenshot of xcode linking libc++ and libz

In a Swift Package Manager project, this can be achieved by adding the following to your target linkerSettings:

// 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.

Build dependencies

If you want to build libtesseract from source, you need automake, pkg-config, and task installed on your machine. These can be installed via homebrew:

brew install automake pkg-config go-task/tap/go-task

To build a library for distribution run task build-tesseract-xcframework-zip

Attributions

libtesseract disributes the following dependencies in binary form:

Description

  • Swift Tools 5.3.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sun Apr 14 2024 09:44:43 GMT-0900 (Hawaii-Aleutian Daylight Time)