arrrrny/tesseract_ocr

BUG: Not working on iOS devices

HTMHell opened this issue · 7 comments

try fileManager.createSymbolicLink(at: sourceURL, withDestinationURL: destURL)

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/

@arrrrny can you take a look at this?

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

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.

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:
- assets/
- assets/tessdata/
- images/

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

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.

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

  • thread #1, queue = 'com.apple.main-thread', stop reason = 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).
    frame #0: 0x00000001afe1923c libswiftCore.dylib_swift_runtime_on_report libswiftCore.dylib:
    -> 0x1afe1923c <+0>: ret
    libswiftCore.dylib: 0x1afe19240 <+0>: b 0x1afe1923c ; _swift_runtime_on_report libswiftCore.dylib:
    0x1afe19244 <+0>: adrp x8, 366028
    0x1afe19248 <+4>: ldrb w0, [x8, #0x994]
    Target 0: (Runner) stopped.
    Lost connection to device.

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