<div dir="ltr"><div>Hi All,</div><div><br></div><div>In the last couple of weeks I’ve been building small Swift servers and interacting with the young ecosystem of public SwiftPM packages. One thing that quickly came up is the need to track down which of my dependencies (or any of its parents) is pulling in this one broken dependency, so that I can fix or work around it.<br></div><div><br></div><div>This quickly becomes a very tedious task, because the SwiftPM packages I’ve encountered are usually small (npm style), which leads to relatively large dependency trees even for moderate-size frameworks.</div><div><br></div><div>To assist developers in easily looking up a misbehaving package or quickly understanding how SwiftPM arrived at a resolved version, I propose we add a new mode to swift-build. This mode would simply dump the dependency tree of the root package into the console.</div><div><br></div><div>Usage could look like this:</div><div>```</div><div>swift build --dump-dependency-tree</div><div>```</div><div>which would print the dependency tree, having the root package as the root of the tree, growing down from there.</div><div><br></div><div>The metadata I suggest we include in each node:</div><div>- Package name</div><div>- Package version range</div><div>- Package remote URL (to easily detect conflicting forks)</div><div>- Package dependencies as the children of this node</div><div><br></div><div>This could be used for:</div><div>- detecting conflicting forks in the dependency tree</div><div>- understanding conflicting version ranges of dependencies</div><div>- graphing the dependency tree in a graphing app, into an image (think centralized SwiftPM index which can show you a clickable dependency tree)</div><div>- debugging/testing of SwiftPM</div><div><br></div><div>There are a couple of formats we could output the tree in</div><div>- .gv (<a href="https://en.wikipedia.org/wiki/DOT_(graph_description_language)">https://en.wikipedia.org/wiki/DOT_(graph_description_language)</a>)</div><div>- Pretty text-based tree for quick CLI viewing</div><div>- JSON</div><div><br></div><div>Personally, I think we should print in the text-based form by default and add an option to output the tree in the .gv format, which can be consumed by many apps e.g. OmniGraffle for further processing.</div><div><br></div><div>Overall I think it’d be a nice feature to have for all the reasons outlined above, but primarily it’s a good way to make the version-resolution magic more transparent.</div><div><br></div><div>I appreciate all feedback. If you think this should be turned into a formal proposal, I can also do that.</div><div><br></div><div>Honza Dvorsky</div><div><br></div><div><br></div></div>