TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

How do I configure my application to receive an AppleEvent?

Forums > macOS

I'm working on an application to queue up work (URLs to fetch) and then batch do the work upon request. I'd like to be able to send an AppleEvent (via an AppleScript) with a URL to my app, semantically saying, "Add this URL to your list of stuff to do."

So, what do I have to do withing my SwiftUI application to make it able to receive such a message?

3      

The only tutorial I'm aware of that uses Swift instead of ObjC is the following from 2016. Also, it looks llike you have to use NSApplication, not the new App struct, but that doesn’t preclude SwiftUI.

https://www.raywenderlich.com/1033-making-a-mac-app-scriptable-tutorial

It might be easier to use an x-callback-url instead of AppleScript:

https://github.com/ValentinWalter/Middleman

I've thought about this myself, which is why I have bookmarks to these resources, but I haven’t actually tried it. I hope you post any tips you develop.

4      

Thanks for these references! I'm in the middle of moving, but this will likely be my next project in a couple of weeks. I'll definitely write an update!

3      

Hacking with Swift is sponsored by String Catalog.

SPONSORED Get accurate app localizations in minutes using AI. Choose your languages & receive translations for 40+ markets!

Localize My App

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.