Unable to build swift-book via docc

Hi. I'm trying to build the swift-book project locally but I'm getting the error below when running swift run docc preview TSPL.docc via the Terminal:

error: Could not find Package.swift in this directory or any of its parent directories.

The build instructions from swift-book do not mention anything related to a Package.swift file.

Maybe you are using a wrong command:

swift run docc preview TSPL.docc means you will call swift compile to build and run a package's product named "docc" and pass "preview TSPL.docc" as its arguments params so it needs a file named Package.swift in the current working directory.

However according to README.md of swift-book, there is no Package.swift and you should call docc preview TSPL.docc to directly preview it. If you do not have docc in you $PATH, you can use xcrun docc to find the docc executable of your Xcode's default Swift Toolchain on macOS.

so the final command you may consider to use is. xcrun docc preview TSPL.docc

Update: Add a PR for it. cc @krilnon @Alex_Martini

1 Like

Thanks! That worked for me. I assume they don't list such an explanation given they just point to the Swift-DocC repo for instructions but that's not even listed there.

Thanks for pointing this out! I added some comments to the PR, but I agree that we should add more details so folks don't stumble over this again.