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?


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.

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

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.


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!


Hacking with Swift is sponsored by Superwall.

SPONSORED Superwall lets you build & test paywalls without shipping updates. Run experiments, offer sales, segment users, update locked features and more at the click of button. Best part? It's FREE for up to 250 conversions / mo and the Superwall team builds out 100% custom paywalls – free of charge.

Learn More

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.