visionOS DOCC command line build documentation fails

Hi, I am working on a visionOS Swift Package.

I'm trying to generate the documentation for preview and export with the following commands, however I keep getting the error:

/Users/chris/myfile.swift:6:8: error: no such module 'UIKit' import UIKit - I'm using UIKit for a color variable.

My Package has:

...
platforms: [.visionOS(.v1)]
...

Failing Commands:

swift package --disable-sandbox preview-documentation

and

PACKAGE_NAME=packageName
REPOSITORY_NAME=repoName
OUTPUT_PATH=./docs

swift package --allow-writing-to-directory $OUTPUT_PATH \
  generate-documentation --target $PACKAGE_NAME \
  --disable-indexing \
  --transform-for-static-hosting \
  --hosting-base-path $REPOSITORY_NAME \
  --output-path $OUTPUT_PATH

The documentation does build if I build it from within Xcode's Product->Build Documentation menu

Does anyone have any ideas what's wrong here?

Replies

You can't pass destination to generate-documentation, instead you can use xcodebuild:

PACKAGE_NAME=packageName
REPOSITORY_NAME=repoName
OUTPUT_PATH=./docs
DOCC_FLAGS="--allow-writing-to-directory $OUTPUT_PATH generate-documentation --target $PACKAGE_NAME --disable-indexing --transform-for-static-hosting --hosting-base-path $REPOSITORY_NAME --output-path $OUTPUT_PATH"

xcodebuild docbuild \
-scheme $PACKAGE_NAME \
-destination generic/platform=visionOS \
OTHER_DOCC_FLAGS="$DOCC_FLAGS"