So I have been browsing the web for a while now and can’t seem to find an answer on how to build the native DocC Xcode documentation using a CLI command.
Both the xcodebuild
commands and Fastlane do not provide a command to build the documentation – as far as I know.
The docs are supposed to be built inside a CI/CD Github Actions workflow. If there are other methods to accomplish this, any help is appreciated.
3
Answers
Apple has added a new command to
xcodebuild
tools:You can also take a look at the WWDC presentation "Host and automate your DocC documentation". Start watching from 7:06 min onwards for DocC automation: https://developer.apple.com/videos/play/wwdc2021/10236/
To complement the initial answer, I’d like to mention this complete summary of all the WWDC21 videos regarding DocC that contains precious information about automation. 🤓
Indeed, there’s a feature in Xcode 13 for building documentation through the command line that includes the docbuild action with many possible options as described below. 🤩
Besides, Xcode 14 fosters the DocC archive content deployment at the root of a web server thanks to its new compatibility with most web servers. 🤩
Even if a solution has already been provided by @Colin 👍, I deemed it important to append some information that may be crucial for some. 😉
Host and Automate your DocC documentation ☁️
Tl;dr
I tweaked the
xcodebuild docbuild
for modular projects as below:I also tweaked the
docc
site generation using thetransform-for-static-hosting
flag:BONUS: Automate DocC with GitHub Pages and CI 🍀
I’ve updated the original demo showcased at WWDC with support for static hosting of modular App targets (rather than only supporting a single Swift Package announced at WWDC) using GitHub Pages without needing to define a server configuration for convenience in my blog post.