zeitlings / alfred-workflows

Collected Alfred Workflows & Proof of Concept
MIT License
164 stars 5 forks source link

OCR can not be run on macOS 12 #6

Closed yoncise closed 1 year ago

yoncise commented 1 year ago

When running the plugin on macOS 12, I find no texts can be recognized.

Running the Swift script directly, I can see these errors:

R.swift:89:20: error: 'init(filePath:directoryHint:relativeTo:)' is only available in macOS 13.0 or newer
                AlfredOCR.snap = URL(filePath: PATH)
                                 ^
/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2AAA757D-05F1-4D04-8A46-C1A9B8BA5B28/AlfredOCR.swift:89:20: note: add 'if #available' version check
                AlfredOCR.snap = URL(filePath: PATH)
                                 ^
/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2AAA757D-05F1-4D04-8A46-C1A9B8BA5B28/AlfredOCR.swift:84:7: note: add @available attribute to enclosing instance method
        func validate() -> Never? {
             ^
/Alfred/Alfred.alfredpreferences/workflows/user.workflow.2AAA757D-05F1-4D04-8A46-C1A9B8BA5B28/AlfredOCR.swift:82:1: note: add @available attribute to enclosing extension
extension FileManager {
^

I need to change AlfredOCR.snap = URL(filePath: PATH) to AlfredOCR.snap = URL(fileURLWithPath: PATH) to let the plugin run successfully.

zeitlings commented 1 year ago

Thanks, taken into account for v1.1.1 (code)