Is the `swift symbolgraph-extract` tool redundant?

i’ve recently become aware that it is possible to emit symbol graphs as part of the compilation process, by passing the -emit-symbol-graph option through swift build. this seems like a much easier way to generate symbol documentation than by manually invoking swift symbolgraph-extract with include paths.

are there any reasons to use swift symbolgraph-extract in place of -emit-symbol-graph today?

1 Like

I find it very valuable to be able to extract symbol graphs from already-compiled modules. If you don't want the symbol graphs, you don't need to request them, and if you do (but perhaps conditionally), you can do it without invalidating your entire build because you don't have to rerun the full compilation with a different flag.

1 Like

thanks! i’m using this in a continuous-build system specifically for generating documentation to host on Swiftinit, so i’m not concerned about incremental builds. i’m mostly just interested in knowing if this is a “officially” supported way to produce symbol graphs

As a concrete example of where this is useful, the Bazel Swift rules use symbol graphs for test discovery. We don't want to have to push information down into the build graph to build test dependencies differently depending on whether they're in a test's build graph or not (more cache misses when the configurations differ), so swift-symbolgraph-extract lets us share the same compiled artifacts and do the extraction in parallel, one step higher once its corresponding module has been compiled.