How to share code between package plugins

I am writing multiple SPM command plugins and would like them to depends on a shared common library target to avoid code duplication.

Apparently, the only way to do it today it to have the plugins depend on a executableTarget and have the executables share library target.

Another option would be to use symlinks (as per Difficulty Sharing Code Between Swift Package Manager Plugins - #6 by itaiferber)

Is this correct ? Is there any discussion happening / plans to ease the requirements on plugins ?

AFAICT you are correct, the best approach I've found is to have an absolutely minimalistic plugin that drives a command line tool that can have other dependencies. If you have multiple plugins, use multiple command lines tools (that can share other target dependencies as needed).

It's a bit unexpected at first (especially since one can add dependencies for the plugin - just not how you expect...).

1 Like

OK - thank you for having confirmed I understood correctly. I hope this can be improved in future releases.