Add a keyboard shortcut to Swift package command plugins

Add a keyboard shortcut to Swift package command plugins

Β·

1 min read

In this blog post I will explain how you can define a keyboard shortcut to quickly trigger a Swift package command plugin in Xcode 14.

Screen Shot 2022-06-22 at 6.57.16 AM.png

If you are unfamiliar with Swift package plugins and their recent Xcode integration, I recommend reading the following article.

Unfortunately, it is not possible to define a key binding from the Xcode preference πŸ˜”

Missing Option in Key Bindings Xcode Preferences

No Shortcut

I created a feedback item for Apple .. maybe this functionality will get added in the future. But there is a workaround!

A big shoutout and thanks to Martin Fiebig who explained this workaround to me πŸ™

You can bind any menu command via your Mac's System Preferences. Select Keyboard -> Shortcuts -> App Shortcuts and add a new item.

IMPORTANT: The menu title needs to be an exact match!

Screen Shot 2022-06-22 at 6.56.26 AM.png

Screen Shot 2022-06-22 at 6.56.41 AM.png

You will see the shortcut in Xcode once you added the app shortcut.

Screen Shot 2022-06-22 at 6.57.16 AM.png

And here is the proof that it works 😊

Demonstration