feedback-assistant / reports

Open collection of Apple Feedback Assistant reports
228 stars 2 forks source link

FB9281486: Provide a high-level API to access and run shortcuts #222

Open sindresorhus opened 3 years ago

sindresorhus commented 3 years ago

Description

It’s awesome that macOS now has Shortcuts, but the suggested way for apps to list and run shortcuts is a bit archaic.

From the WWDC21 talk on Shortcuts:

Using the Scripting Bridge framework, you can ask the Shortcuts Events process to run a shortcut directly from your Swift or Objective-C apps.

A lot of apps would benefit from being able to run Shortcuts. For example, a calendar app could let the user pick a shortcut to run when an event starts. There are just so many cool opportunities. But the Scripting Framework is archaic, buggy, and slow, which will deter a lot of apps from bothering.

I would suggest adding some high-level APIs to list and run Shortcuts.

For example:

let shortcut = NSWorkspace.shared.shortcuts.first(where: \.name == "Unicorn")!

await shortcut.run()
sindresorhus commented 2 years ago

My reply:


I’m implementing the Scripting Bridge way in an app of mine and it takes 5 seconds (!) on a fully specced MacBook Pro (16-inch, 2021) to fetch 30 shortcuts. That is not a good user-experience…

There’s also no way to get notified when shortcuts change, so I have to refetch them every time the window regains focus.