And interestingly due to some very clever integrations[0], sending Apple Events (the underlying tech for the actual IPC communication done with AppleScript) is very easy to do in Swift. Easier than in AppleScript actually!
It’s a shame most apps do not support Apple Events anymore, though.
An example of use: https://github.com/Frizlab/apple-music-to-slack/blob/90964bb...