arrrrny / tesseract_ocr

Tesseract OCR for flutter
BSD 3-Clause "New" or "Revised" License
96 stars 88 forks source link

BUG: Not working on iOS devices #31

Closed HTMHell closed 3 years ago

HTMHell commented 3 years ago

https://github.com/arrrrny/tesseract_ocr/blob/7e915045c80578d05fd0172418260bea453058ad/ios/Classes/SwiftTesseractOcrPlugin.swift#L47

When running via iPhone, I'm getting the following error message:

Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “tessdata” in the folder “MyApp”." UserInfo={NSFilePath=/var/containers/Bundle/Application/8A5B1F0C-6BB3-47F1-98D3-74BF4701FB47/Runner.app/tessdata, NSUnderlyingError=0x282729fb0 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}

I've debugged it and found the causing line. When the error was thrown, I also printed the content of the variables sourceURL and destURL:

(lldb) vo sourceURL (URL) sourceURL = ▿ file:///var/containers/Bundle/Application/8A5B1F0C-6BB3-47F1-98D3-74BF4701FB47/Runner.app/tessdata

  • _url : file:///var/containers/Bundle/Application/8A5B1F0C-6BB3-47F1-98D3-74BF4701FB47/Runner.app/tessdata

(lldb) vo destURL (URL) destURL = ▿ file:///var/mobile/Containers/Data/Application/D1CAAF6E-5D63-42ED-9324-6D90FDB19447/Documents/tessdata/

  • _url : file:///var/mobile/Containers/Data/Application/D1CAAF6E-5D63-42ED-9324-6D90FDB19447/Documents/tessdata/
HTMHell commented 3 years ago

@arrrrny can you take a look at this?

siva3392 commented 3 years ago

Did you added tessdata under assets folder in pubspec.yaml?

HTMHell commented 3 years ago

Did you added tessdata under assets folder in pubspec.yaml?

Yes, I did.

Also, everything works fine on Android devices, and on an iOS simulator.

brannendl commented 3 years ago

I'm having the same issue. Works great on Android. Flutter 1.26.0-12.0.pre, Dart 2.12.0 (build 2.12.0-224.0.dev), SwiftyTesseract (2.2.3), Xcode Version 12.4 (12D4e).

tesseract_ocr: git: url: git://github.com/arrrrny/tesseract_ocr.git

assets:

siva3392 commented 3 years ago

Just drag tessdata folder from asset to place under Runner folder in xcode add as a reference then it will work.

HTMHell commented 3 years ago

Just drag tessdata folder from asset to place under Runner folder in xcode add as a reference then it will work.

That'll work, but will increase the size of the app. Contents of tessdata folder will be both in the app bundle and the documents bundle.

RubanRaguraj commented 1 year ago

Note:-

This plugin was not working in physical device for mac ios please tell me the solution for that.

check the below Error message for your reference.

[core] "Error returned from daemon: Error Domain=com.apple.accounts Code=7 "(null)"" [PAAccessLogger] Failed to log access with error: access=<PATCCAccess 0x2820a1ae0> accessor:<<PAApplication 0x2820a2210 identifierType:auditToken identifier:{pid:655, version:1816}>> identifier:858B32E1-AC9F-4A2B-A9D6-9BD18695C94A kind:intervalEvent timestampAdjustment:0 visibilityState:0 assetIdentifierCount:0 tccService:kTCCServicePhotos, error=Error Domain=NSCocoaErrorDomain Code=4097 "connection to service with pid 230 named com.apple.privacyaccountingd" UserInfo={NSDebugDescription=connection to service with pid 230 named com.apple.privacyaccountingd} ℹ️-[TSDBLogger db_save] Log committed [GETX] CLOSE DIALOG 826183865 Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “tessdata” in the folder “Dev ieXchange”." UserInfo={NSFilePath=/private/var/containers/Bundle/Application/378508D2-3E45-4576-B171-41242A021A9B/Runner.app/tessdata, NSUnderlyingError=0x280cc6b50 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}} Error opening data file /private/var/containers/Bundle/Application/378508D2-3E45-4576-B171-41242A021A9B/Runner.app/tessdata/eng.traineddata Please make sure the TESSDATA_PREFIX environment variable is set to your "tessdata" directory. Failed loading language 'eng' Tesseract couldn't load any languages! SwiftyTesseract/SwiftyTesseract.swift:100: Fatal error: Initialization of SwiftyTesseract has failed. Check that the tessdata folder has been added to the project as a folder reference and contains the correct .traineddata files for the specified engine mode and language(s). SwiftyTesseract/SwiftyTesseract.swift:100: Fatal error: Initialization of SwiftyTesseract has failed. Check that the tessdata folder has been added to the project as a folder reference and contains the correct .traineddata files for the specified engine mode and language(s).

Plugin :- flutter_tesseract_ocr: ^0.4.23

My credential:- Flutter (Channel stable, 2.10.3, on macOS 13.3 22E252 darwin-arm, locale en-IN) [!] Android toolchain - develop for Android devices (Android SDK version 34.0.0) ✗ Android license status unknown. Run flutter doctor --android-licenses to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 14.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.1) [✓] VS Code (version 1.75.0) [✓] Connected device (2 available) [✓] HTTP Host Availability