cueward-adapter-macos 0.5.0

macOS adapter for Cueward with Safari, Notes, Messages, Reminders, Calendar, Screenshot, Clipboard, and OCR integrations.
1
2
3
4
5
6
7
8
9
10
import Cocoa
import ObjectiveC
let fixtureURLs = CommandLine.arguments.dropFirst().map { URL(fileURLWithPath: $0) as NSURL }
let single: @convention(block) (AnyObject, NSString) -> NSURL? = { _, _ in fixtureURLs.first }
let plural: @convention(block) (AnyObject, NSString) -> NSArray = { _, _ in fixtureURLs as NSArray }
let cls = object_getClass(NSWorkspace.shared)!
let singleSelector = #selector(NSWorkspace.urlForApplication(withBundleIdentifier:))
let pluralSelector = #selector(NSWorkspace.urlsForApplications(withBundleIdentifier:))
class_replaceMethod(cls, singleSelector, imp_implementationWithBlock(single), method_getTypeEncoding(class_getInstanceMethod(cls, singleSelector)!))
class_replaceMethod(cls, pluralSelector, imp_implementationWithBlock(plural), method_getTypeEncoding(class_getInstanceMethod(cls, pluralSelector)!))