I've taken the code from the WWDC video and are trying to run a shortcut via ScriptingBridge:
import ScriptingBridge
@objc protocol ShortcutsEvents {
@objc optional var shortcuts: SBElementArray { get }
}
@objc protocol Shortcut {
@objc optional var name: String { get }
@objc optional func run(withInput: Any?) -> Any?
}
extension SBApplication: ShortcutsEvents {}
extension SBObject: Shortcut {}
and
guard
let app: ShortcutsEvents = SBApplication(bundleIdentifier: "com.apple.shortcuts.events"),
let shortcuts = app.shortcuts else { throw "error" }
print("getting short")
guard let shortcut = shortcuts.object(withName: shortcutName) as? Shortcut else { throw "error" }
print("running short", shortcut)
let res = shortcut.run?(withInput: input)
print("shotcut result", res ?? "nil")
While I am getting the shortcut object just fine
running short <SBObject @0x6000035c8e40: <class 'srct'> "append" of application "Shortcuts Events" (16450)>
running it, just does nothing and returns nil
shotcut result nil
Running the shortcut via cli works as expected.
I (hopefully) have set the entitlements correctly
but I am feeling a little stumped not to even get an error at all.
What am I doing wrong there?