Search code examples
iosswiftocrtesseract

Missing required Modules "libtesseract libleptonica"


I downloaded this project(github), build and took the .framework file into my test project. Then I embed and sign that swiftytesseract.framework file like in attached image. enter image description here

Xcode screenshots

I am able to build and run my app

Now I gave this code to another developer and when he build and run the code he is getting a compiler error "Missing required modules libtesseract and libleptonic"

here is my app code

import UIKit
import SwiftyTesseract

class ViewController: UIViewController {
    @IBOutlet weak var txt: UILabel!

    fileprivate let tesseract = SwiftyTesseract(language: .custom("ocrb"), bundle: Bundle(for: ViewController.self), engineMode: .tesseractLstmCombined)
    @IBOutlet weak var img: UIImageView!
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }

    @IBAction func ocr(_ sender: Any) {
        let image = UIImage(named: "sample")!
               let result: Result<String, Error> = tesseract.performOCR(on: image)
               print(result)
    }

}

Solution

  • Create module.modulemap file at root directory like that:

    module libtesseract {
    header 
    "yourpath/dependencies/include/tesseract/capi.h"
    export *
    }
    
    module libleptonica {
    header 
    
    "yourpath/dependencies/include/leptonica/allheaders.h"
    export *
    }