Meet Shortcuts for macOS

RSS for tag

Discuss the WWDC21 session Meet Shortcuts for macOS.

View Session

Posts under wwdc21-10232 tag

10 Posts
Sort by:
Post not yet marked as solved
3 Replies
239 Views
According to the 2021 WWDC video “Meet Shortcuts for macOS”, all I have to do is add the Intents file to my application, build it, and immediately the actions will be available in Shortcuts/Mac. This is most definitely not my experience, I've added the Intents file, configured some intents, and build my application, but nothing shows up in Shortcuts. So clearly I am missing something. My Application is an Objective C++ app, designed to run in the background (Keyboard Maestro Engine), and I'm trying to add some Shortcut actions to it, but I have had no luck getting them to appear at all. Any suggestions on what to try or what more I need to do to get them to show up?
Posted
by
Post not yet marked as solved
5 Replies
426 Views
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?
Posted
by
Post not yet marked as solved
3 Replies
735 Views
I have an existing iOS app with shortcuts support, and I am trying to bring the same shortcuts to my Mac app in macOS Monterey. In my case, I have added the same intents definition file to my Mac target app, added "Intents eligible for in-app handling" to my Info.plust file and added the intent names, and made sure all the intent handling code is part of both iOS and Mac targets. Still, when I build and run the app on macOS Monterey, the new shortcuts don't show in the shortcut editor at all. I've tried closing and restarting the Shortcuts app, but no luck. The build logs do show the intents being built, but they're just not showing up in the Shortcuts app. I tried 'donating' one of the intents in my Mac app code, but got an error: Cannot donate interaction with intent that has no valid shortcut types Not sure what to try to make it work. Thanks.
Posted
by
Post not yet marked as solved
6 Replies
777 Views
Hi, I have developed a Shortcuts action for the new Shortcuts of macOS 12. I've created a custom intent and an Intents extension. My action receives one or more files as input. The file type has been set to a custom UTI com.adobe.pdf. However the files cannot be opened. I can see in the Console that Sandbox denies the access.  If I handle the intent directly in my main app with func application(_ application: NSApplication, handlerFor intent: INIntent) -> Any? I can only open files that have been opened by the main app before. If I handle the intent in an app extension I can't open any file at all. Both the main app and the extension are sandboxed with com.apple.security.files.user-selected.read-only set to 1. My app is singed with my valid developer ID. The example Shortcut workflow I've build simply receives PDFs as an input and is set-up to work as a Quick Action. But no matter which Shortcut configuration I choose, it does not seem to make a difference. Interestingly everything works as expected if I set com.apple.security.files.downloads.read-write to 1. Of cause that only works with the Downloads folder. My question: How do I have to configure my app and/or app extension in order to work with files that have been opened in Shortcuts and given to my Shortcut action as an input parameter. Cheers and thanks for your help
Posted
by
Post marked as solved
2 Replies
347 Views
Hi All, I'm using Core Data to store my data. I've followed the guide in the video but unable to complete the final steps. /// The core data stack `Data`     var dataProvider: datasProvider = .shared          func handle(intent: CreateNoteIntent, completion: @escaping (CreateNoteIntentResponse) -> Void) {         let title = intent.title!         let isBookmark = intent.isBookmark!         let photo = UIImage()                  let newIntent = Task { await self.dataProvider.addData(time: Date(), title: title, isFavorite: isBookmark as! Bool, image: photo) }                  let response = CreateNoteIntentResponse(code: .success, userActivity: nil)         response.noteIntent = newIntent //Error: Cannot assign value of type 'Task<(), Never>' to type 'Type'         completion(response)     } I'm using SwiftUI and it is for iOS app. Does anyone have a solution for this or can explain to me what went wrong please. Spent few hours figuring this out. Any help will be appreciated. Thank you.
Posted
by
Post marked as solved
1 Replies
447 Views
I’m trying to implement the code like shown in the session but problems start early — there seems to be no such thing like a CreateTaskIntentHandling class even after importing Intents. Cannot find type 'CreateTaskIntentHandling' in scope What am I missing here? masOS Monterey Version 12.0 Beta (21A5506j) Xcode Version 13.0 RC (13A233)
Posted
by
Post not yet marked as solved
0 Replies
540 Views
I'm trying to run Shortcuts programmatically on Monterey. My understanding is that the official API for this is via AppleScript to the Shortcuts Events process. I created a Shortcut that does Quicklook on the passed in file parameter. It works as a Finder action but I can't figure out how to get it to work when running it via AppleScript or Scripting Bridge. If I send a file, alias or POSIX file, I get a generic Shortcuts error 4. If I send a path as a string, it just does a preview of the string passed in, and not the contents of the file the path references. Anyone have any insight on how to get this working?
Posted
by
Post not yet marked as solved
1 Replies
537 Views
Hi, I'm trying to integrate shortcuts into my app, I knew there are 2 ways to do that, 1. Via main app. 2. Use an intent extension. When I use method 1 after I add an intent definition file and create a custom intent then specify "Supported Intents" in main app target and write the logic code in appdelegate, every thing works smoothly. But When I turned to intent extension, after I create an intent extension, it seems extension target doesn't support to specify the intent. Then I fill the configuration in intent extension manually, then build my app. I think the log should print like it did when I use main app method but it didn't. So I wonder that s this means current beta4 sdk not support custom intent extension on MACOS or I missed something? Thanks.
Posted
by
Post not yet marked as solved
0 Replies
429 Views
We are trying to create shortcut actions with Catalyst. Our app is already available on Mac, and we integrated the intents framework on iOS. So according to the WWDC21 "Meet Shortcuts on macOS" presentation, "it's likely that [we] have compiled out [our] Intents integration in the process of coming to Mac". The presentations suggests to "make sure to audit your code to re-enable this functionality when running on macOS Monterey." We have not found how to "re-enable this functionality". Any suggestion on how to create shortcut actions for Mac in this situation ?
Posted
by
Post marked as solved
1 Replies
655 Views
Hello, Created one demo for creating task. But it does not work properly. When execute Shortcut from 2021-06-16 16:18:07.947665+0530 TestTask[28602:364855] [logging-persist] cannot open file at line 45068 of [d880193994] 2021-06-16 16:18:07.947700+0530 TestTask[28602:364855] [logging-persist] os_unix.c:45068: (0) open(/var/db/DetachedSignatures) - Undefined error: 0 Not sure, reason behind it
Posted
by