Created
March 25, 2026 11:24
-
-
Save iliaskarim/f0827c4860e97e287cc8b8b17f752ebc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| set -ex | |
| # toolchain paths – adjust if Xcode is installed elsewhere | |
| DOCC="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/docc" | |
| # derive scheme name from the current directory (assumes project directory | |
| # name matches the product/scheme name). | |
| SCHEME="$(basename "$(pwd)")" | |
| # when serving from a subpath (e.g. GitHub Pages), use a hosting base path | |
| # default assumes the documentation will live under /<SchemeName> on the | |
| # web server. passing `--no-base` on the command line will disable this | |
| # behavior and omit the flag entirely (resulting in root-relative resource | |
| # links). | |
| HOSTING_BASE_PATH="/$SCHEME" | |
| # simple boolean flag parsing; recognize --no-base to clear the path | |
| while [[ $# -gt 0 ]]; do | |
| case "$1" in | |
| --no-base) | |
| HOSTING_BASE_PATH="" | |
| shift | |
| ;; | |
| *) | |
| echo "Unknown argument: $1" >&2 | |
| exit 1 | |
| ;; | |
| esac | |
| done | |
| # clean docs | |
| rm -rf .build build docs | |
| HOSTING_ARGS=() | |
| [ -n "$HOSTING_BASE_PATH" ] && HOSTING_ARGS=(--hosting-base-path "$HOSTING_BASE_PATH") | |
| # build docs | |
| xcodebuild docbuild \ | |
| -scheme "$SCHEME" \ | |
| -destination 'platform=macOS,arch=arm64,name=My Mac' \ | |
| -derivedDataPath build > /dev/null | |
| $DOCC process-archive transform-for-static-hosting \ | |
| --output-path ./docs \ | |
| "${HOSTING_ARGS[@]}" \ | |
| "./build/Build/Products/Debug/$SCHEME.doccarchive" > /dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment