Integrate OCR capabilities into your iOS app

This guide provides step-by-step instructions for integrating the Nutrient iOS OCR library into your project.

Prerequisites

Ensure you have the following before integrating the Nutrient iOS OCR library:

Quick start with the Catalog example

To see OCR in action, run the OCRExample.swift code sample in the Nutrient Catalog sample project:

  1. Open Catalog.xcodeproj.

  2. Build and run the Catalog scheme.

  3. Search for OCR in the examples list and open the relevant example.

Integrating the Nutrient iOS OCR library

There are three ways to integrate the Nutrient iOS OCR library into your project:

  • Using Swift Package Manager

  • Using CocoaPods

  • Manual integration

Each of these approaches are outlined below.

Swift Package Manager (SwiftPM)

To add PSPDFKitOCR to your project using SwiftPM, follow the steps below:

  1. Integrate the Nutrient Swift package into your project.

  2. Add PSPDFKitOCR using our public repository URL.

add-swift-package
  1. Download the latest language files.

  2. Manually add the required language files to your project.

add-language-file-bundle

CocoaPods

To integrate PSPDFKit and PSPDFKitOCR using CocoaPods, follow the steps below.

  1. Add the following dependencies to your Podfile:

use_frameworks!

target :YourTargetName do
	pod 'PSPDFKit',
	    podspec: 'https://my.nutrient.io/pspdfkit-ios/latest.podspec'
	pod 'PSPDFKitOCR',
	    podspec: 'https://my.nutrient.io/ocr/latest.podspec'
end
  1. Install the dependencies:

pod install
  1. By default, PSPDFKitOCR includes trained data models for all supported languages. To reduce app size, include only the required languages by modifying your Podfile as shown below:

use_frameworks!

target :YourTargetName do
	pod 'PSPDFKit',
	    podspec: 'https://my.nutrient.io/pspdfkit-ios/latest.podspec'

	pod 'PSPDFKitOCR/PSPDFKitOCR',
	    podspec: 'https://my.nutrient.io/ocr/latest.podspec'

	pod 'PSPDFKitOCR/English',
	    podspec: 'https://my.nutrient.io/ocr/latest.podspec'

	pod 'PSPDFKitOCR/German',
	    podspec: 'https://my.nutrient.io/ocr/latest.podspec'
end

Manual integration

To integrate PSPDFKitOCR manually:

  1. Integrate Nutrient into your project.

  2. Drag PSPDFKitOCR.xcframework into the Frameworks, Libraries, and Embedded Content section of your target.

  3. Add the necessary language files from PSPDFKitOCR/Languages to your project.

add-language-file-bundle

Next steps

To learn how to perform OCR on PDFs in iOS, refer to the performing OCR guide.