Run swift package generate-documentation on the Mac, pull the .doccarchive to your workstation with rsync, and either open it in Xcode or serve its static HTML. DocC compiles your target while it generates documentation, so the Mac must be able to build the module. References: Apple's DocC documentation and the Swift-DocC Plugin repository.
How do I run the DocC plugin?
Clone your package on the Mac, then invoke the plugin through Swift Package Manager:
swift package \
--allow-writing-to-directory ./docs \
generate-documentation \
--target MyLibrary \
--output-path ./docs \
--transform-for-static-hosting
--allow-writing-to-directory is the SwiftPM permission gate for plugins that write outside the build folder, and without it the plugin aborts. --transform-for-static-hosting rewrites the archive's internal links so a plain file server can serve it. --hosting-base-path <path> adds a URL prefix such as /docs/MyLibrary for GitHub Pages. The plugin exits non-zero on a compile failure, so set -e in a wrapper script does the right thing.
For a package with several targets, run the command once per target with a distinct --output-path. Flags after generate-documentation are forwarded to the underlying docc tool, and the Swift-DocC Plugin repository lists them for the version you install.
How do I build and pull the archive with one script?
This script runs the DocC build over SSH, then rsyncs the archive back to your workstation:
#!/usr/bin/env bash
# build-docc.sh
# Usage: ./build-docc.sh user@remote-mac /path/to/package TargetName [/local/output]
set -euo pipefail
REMOTE="$1"
REMOTE_PKG="$2"
TARGET="$3"
LOCAL_OUT="${4:-./doccarchive}"
REMOTE_OUT="/tmp/docc-${TARGET}"
echo "==> Building DocC for ${TARGET} on ${REMOTE}"
ssh "${REMOTE}" "cd '${REMOTE_PKG}' && \
swift package \
--allow-writing-to-directory '${REMOTE_OUT}' \
generate-documentation \
--target '${TARGET}' \
--output-path '${REMOTE_OUT}' \
--transform-for-static-hosting"
mkdir -p "${LOCAL_OUT}"
echo "==> Pulling archive to ${LOCAL_OUT}"
rsync -avz --delete \
"${REMOTE}:${REMOTE_OUT}/${TARGET}.doccarchive" \
"${LOCAL_OUT}/"
echo "==> Done. Open ${LOCAL_OUT}/${TARGET}.doccarchive in Xcode or serve it over HTTP."
The script is a worked example, not a benchmarked pipeline. Run it against your own package and target names, and do not assume a .doccarchive path exists before a successful build.
How do I host the archive?
A .doccarchive built with --transform-for-static-hosting contains an index.html and a data/ directory, and any static host can serve it.
GitHub Pages:
cp -r ./doccarchive/MyLibrary.doccarchive/* docs/
touch docs/.nojekyll
git add docs/
git commit -m "docs: regenerate MyLibrary"
git push
Local preview with nginx:
docker run --rm -p 8080:80 \
-v "$(pwd)/doccarchive/MyLibrary.doccarchive:/usr/share/nginx/html:ro" \
nginx
Open http://localhost:8080 and confirm navigation, search and symbol pages render before you publish.
How do I rebuild the docs on every push?
Connect the Mac as a GitHub Actions self-hosted runner (see our self-hosted runner guide) and add a documentation job. Secrets stay in GitHub's secret store, so do not export the whole environment to a file.
name: Build Documentation
on:
push:
branches: [main]
jobs:
build-docs:
runs-on: [self-hosted, macOS]
steps:
- uses: actions/checkout@v4
- name: Generate DocC
run: |
swift package \
--allow-writing-to-directory ./docs \
generate-documentation \
--target MyLibrary \
--output-path ./docs \
--transform-for-static-hosting
- name: Upload archive
uses: actions/upload-artifact@v4
with:
name: MyLibrary-doccarchive
path: docs/
Harden the runner per GitHub's self-hosted runner security guidance. Run only trusted code on it, because a self-hosted runner executes whatever the workflow tells it to.
Which Figment Mac plan fits my package?
Match the plan to what the package imports.
- Pure Swift, or AppKit and Foundation on macOS: the Intel Mac VM ($25 a month, $2 a day) runs macOS Sequoia, where Apple lists Xcode 26.0 to 26.3, so a toolchain of Xcode 26.3 or earlier fits. It cannot run arm64-only binaries.
- UIKit with arm64-only simulators, visionOS, Xcode 26.4 or later, or concurrent multi-target builds: use the Apple Silicon Mac VM ($39 a month, $6 a day) or the Dedicated M4 Pro 48 GB ($349 a month, or $299 a month on a 12-month term). Check the macOS version shown before purchase against Apple's Xcode requirements.
Disk matters too. The Intel Mac VM has an 80GB SSD that includes the OS, and the Apple Silicon Mac VM has 65GB. Check that Xcode, DerivedData and the .doccarchive fit for your package.
If you plan to prepay a year for Apple silicon, compare the annual lines. CloudMac lists a Mac mini M4, 16 GB RAM, 256 GB SSD at $99.99 a month, and its home page advertises $999 a year for the same tier ($83.25 a month). The 512 GB and 1 TB rows show "Fully reserved, next allocation not scheduled", and the 256 GB row shows "Reserve now" (checked 2026-11-10). Over twelve months the Apple Silicon Mac VM is 12 × $39 = $468 and the Dedicated M4 Pro 48 GB is $3,228 paid up front. CloudMac's listing is a whole Mac mini, so the Dedicated M4 Pro is the like-for-like Figment plan, with 48GB RAM and 512GB SSD against 16GB and 256GB. See all plans at /mac-hosting.
Related guides: