khjde1207 / tesseract_ocr

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

Swift Compile Error Unexpected non-void return value in void function #16

Closed cansavrun closed 2 years ago

cansavrun commented 2 years ago

I am getting Unexpected non-void return value in void function in SwiftFlutterTesseractOcrPlugin.swift while i try to open the plugin example in ios.

khjde1207 commented 2 years ago

Can you show all the error messages?

cansavrun commented 2 years ago

Thank you for your answer. This is the error i am getting when i try to write flutter build ios:

Xcode's output:
↳
    /Users/cansavrun/development/flutter/.pub-cache/hosted/pub.dartlang.org/image_picker-0.7.5/ios/Classes/FLTImagePickerPlugin.m:193:20: warning: 'UIAlertView' is
    deprecated: first deprecated in iOS 9.0 - UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead
    [-Wdeprecated-declarations]
        [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil)
                       ^
    In module 'UIKit' imported from /Users/cansavrun/Desktop/tesseract_ocr-master/example/ios/Pods/Target Support Files/image_picker/image_picker-prefix.pch:2:
    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.5.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIAlertView.h:2
    7:12: note: 'UIAlertView' has been explicitly marked deprecated here
    @interface UIAlertView : UIView
               ^
    1 warning generated.
    1 warning generated.
    warning: [CP] Unable to find matching .xcframework slice in 'ios-arm64 ios-x86_64-maccatalyst ios-x86_64-simulator' for the current build architectures (arm64 armv7).
    /Users/cansavrun/Desktop/tesseract_ocr-master/example/ios/Pods/SwiftyTesseract/SwiftyTesseract/SwiftyTesseract/Enums/EngineMode.swift:9:8: error: no such module
    'libtesseract'
    import libtesseract
           ^
    /Users/cansavrun/Desktop/tesseract_ocr-master/example/ios/Pods/SwiftyTesseract/SwiftyTesseract/SwiftyTesseract/Enums/EngineMode.swift:9:8: error: no such module
    'libtesseract'
    import libtesseract
           ^
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Analyzing workspace
    note: Constructing build description
    note: Build preparation complete

Encountered error while building for device.

This is the error while i try to run on xcode:

Ekran Resmi 2021-09-14 20 44 39

This is where i am getting the error on swift:

else if(call.method == "initswiftyTesseract") { guard let args = call.arguments else { result("iOS could not recognize flutter arguments in method: (sendParams)") return }

        let params: [String : Any] = args as! [String : Any]
        let language: String? = params["language"] as? String
        if(language != nil){
            swiftyTesseract = SwiftyTesseract(language: .custom((language as String?)!))
        }
        return true //this part is giving the error
    }
khjde1207 commented 2 years ago

Please check in the latest version.

cansavrun commented 2 years ago

Hi thank you for your response.Sorry for the late response.Normally application wouldn't open but now it worked.But the current problem is when i push the run button the application is crashing. I am getting this error now: 2021-09-23 14:40:45.728925+0300 Runner[4879:1452660] 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).: file SwiftyTesseract/SwiftyTesseract.swift, line 100

else { fatalError(SwiftyTesseract.Error.initializationErrorMessage) }

khjde1207 commented 2 years ago

https://github.com/arrrrny/tesseract_ocr/issues/31 Can you please check if this method solves it? If it is resolved, can I ask for pull requests?

cansavrun commented 2 years ago

It is resolved. But you can add tessdata only in xcode so i think mentioning this solution in readme will be enough.But if you want i can create a pull request.

khjde1207 commented 2 years ago

good idea. I'll add it to the readme.