Skip to main content

Add a keyboard shortcut to Swift package command plugins

Published 1 min readMarkdown
Add a keyboard shortcut to Swift package command plugins

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

About the author

  • I am a Software Engineer working on open source and enterprise mobile SDKs for iOS and MacOS developers written in Swift. From 馃嚛馃嚜 and happily living in 馃嚭馃嚫

No comments yet. Be the first to comment.

More from this blog