How do you keep the reusable pieces of manifest files updated?

Most of what's in your Package.swifts is going to look the same across packages. When you update that portion, however many files that should use the changes will get out of sync unless you update them somehow. How do people do this?

Being able to import code from a repository into a manifest would help. This seems like the correct solution to me, but it is impossible.

It is fine if people solve this with tools that are not ecosystem-specific. I'd still like to know what they are, because I'm not informed about where to even start looking for modern options.

1 Like

We have a simple Swift script that scans for all Package.swift files in the repository then, in each file, looks for this text

  // --------------------------------------------------------------- //
  // --------------------------------------------------------------- //
  //                                                                 //
  // >>> TOOLING AUTOMATICALLY ADDED BELOW THIS LINE, DON'T EDIT <<< //
  //                                                                 //
  // --------------------------------------------------------------- //
  // --------------------------------------------------------------- //

(if it doesn’t find the text, the script fails) and replaces everything below the text with a common source.

If we need to update something in all package manifests, we update the script file and then run it.

4 Likes

Is this assuming one monorepo?

How about: we can assume that all Package.swifts are found within an organization on GitHub, and also that everyone on the team could have local clones of them all, but there is no usage of a monorepo?

yes, we use this technique in 2 separate monorepos (2 apps), but we have the issue you mentioned, that is, we have several packages that have their own repo and that are shared

luckily in our case, these other repos are not too many, so it’s enough to manually update them when needed, but an option to make it scale would be to define an automation (for example, github action) that, once a specific repo is updated, opens PRs on all other repos to update all package manifests

1 Like

People on the open source Slack were mentioning GitHub - brightdigit/PackageDSL: Simplify the management of your Package.swift file with a type-safe, modular DSL .

I think it would be an interesting evolution for SwiftPM to support features like that natively.