If you want to put together keyboard-shortcut-triggered automations on a Mac without any third party software, I think you have to create an automator service and then assign it a shortcut in System Preferences > Keyboard > Services.
I know you asked about Swift, but...
If you're ok with third party software, I would recommend keyboard maestro. In addition to triggers (keyboard-based and others), it offers a pretty high level API over the macOS automation stuff you'd typically hack together with AppleScript, such as "activate app", "bring window at index i to front", "simulate keystroke", "insert text", "move the mouse to x,y relative to Element", "run JS in frontmost browser tab", etc. And that's only roughly 5% of what it can do.
With keyboard maestro I don't see much point in writing one's own native automation apps. The APIs it exposes are just as powerful as what you could write yourself and a heck of a lot easier to use.
I know you asked about Swift, but...
If you're ok with third party software, I would recommend keyboard maestro. In addition to triggers (keyboard-based and others), it offers a pretty high level API over the macOS automation stuff you'd typically hack together with AppleScript, such as "activate app", "bring window at index i to front", "simulate keystroke", "insert text", "move the mouse to x,y relative to Element", "run JS in frontmost browser tab", etc. And that's only roughly 5% of what it can do.
With keyboard maestro I don't see much point in writing one's own native automation apps. The APIs it exposes are just as powerful as what you could write yourself and a heck of a lot easier to use.