我下载了该项目(github),进行构建并将.framework文件带到我的测试项目中。 然后,我嵌入并签署了swiftytesseract.framework文件,如附件图像中所示。 enter image description here
我能够构建和运行我的应用
现在,我将此代码提供给另一位开发人员,当他构建并运行该代码时,他遇到了编译器错误“缺少必需的模块libtesseract和libleptonic”
这是我的应用代码
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)
}
}
答案 0 :(得分:0)
在根目录下创建module.modulemap文件,如下所示:
module libtesseract {
header
"yourpath/dependencies/include/tesseract/capi.h"
export *
}
module libleptonica {
header
"yourpath/dependencies/include/leptonica/allheaders.h"
export *
}