Determine origin of a SwiftPM Dependency

Hi,

My Xcode project has a vast mixture of dependencies and I want to be able to quickly determine why a certain SPM package is a dependency. The following command

swift package show-dependencies

is useful in a single package because it shows me all of it's downstream dependencies. But I would need to run this on each SPM package in my project and manually note down the packages that mention the package I'm interested in.

Unless I'm going about this all wrong?

It would be great to right click on the package and select an option that shows the upstream dependencies that lead to it's presence in my project. Are there any plans to implement this?

2 Likes

swift package show-dependencies seems to be a more or less equivalent do npm ls -a in that it prints whole recursive dependency tree.

npm ls <dependency> - to find where <dependency> comes from does not seem to have a straight equivalent in swift package manager ecosystem and the closest you can get is to grep(1) around a bit.

I think it should be added to swift.

Is there anything in how swift package show-dependencies --format dot | dot -Tpng > save out.png displays a dependencies graph for a package that you find missing?

You only need graphviz for this to work (brew install graphviz on macOS).