DocC documentation warnings as errors

DocC supports treating build warnings as errors using the --warnings-as-errors flag. Is there a way to pass this flag to xcodebuild docbuild command or do I need to use xcrun docc convert after generating the symbol graph?

Accepted Answer

Xcode has an "Other DocC Flags" build setting—for additional flags to pass to DocC—that you can specify either in the build settings of your Xcode project or on the command line (as OTHER_DOCC_FLAGS).

On the command line you can either override a build setting by directly specifying it as a key-value pair:

xcodebuild docbuild             \
  -scheme NameOfYourScheme      \
  -destination 'platform=macOS' \
  OTHER_DOCC_FLAGS='--warnings-as-errors'

or you can specify any number of build settings in an xcconfig file and pass that file for the -xcconfig command line option:

# create a 'xcconfig' file
echo "OTHER_DOCC_FLAGS = --warnings-as-errors" > MyBuildSettings.xcconfig   

# pass it to xcodebuild
xcodebuild docbuild             \
  -scheme NameOfYourScheme      \
  -destination 'platform=macOS' \
  -xcconfig MyBuildSettings.xcconfig
DocC documentation warnings as errors
 
 
Q