Generate cross-platform documentation

Is is possible to use DocC to generate a single .doccarchive that contains documentation for multiple platforms, e.g. macOS and iOS?

When publishing a package that has a lot of shared code but some differences between platforms it would be nice to not have to publish a website per-platform.

Answered by Developer Tools Engineer in 678408022

When DocC builds documentation for one platform it gets the information from each symbol’s @available attribute to know what platforms and versions each symbol is available for. If a symbol has no explicit availability attribute, DocC assumes that the symbols is available on all platforms.

In the rendered documentation, each symbol displays this availability information to the side in wide viewports, or above the declaration in narrow viewports.

There’s a known issue that symbols that are marked unconditionally unavailable from the platform being built (for example @available(macOS, unavailable)) are excluded from the built documentation.

If you have other use-cases that would benefit from a different structure to the rendered documentation, we’d love to hear about that in a Feedback.

When DocC builds documentation for one platform it gets the information from each symbol’s @available attribute to know what platforms and versions each symbol is available for. If a symbol has no explicit availability attribute, DocC assumes that the symbols is available on all platforms.

In the rendered documentation, each symbol displays this availability information to the side in wide viewports, or above the declaration in narrow viewports.

There’s a known issue that symbols that are marked unconditionally unavailable from the platform being built (for example @available(macOS, unavailable)) are excluded from the built documentation.

If you have other use-cases that would benefit from a different structure to the rendered documentation, we’d love to hear about that in a Feedback.

My use-case is a framework that utilises #if os(...) because some symbols are not available across all platforms (e.g. views that inherit from UIView vs NSView).

The @available parsing is useful, thank you for clarifying how that works.

I will file a feedback with a more complete example.

Generate cross-platform documentation
 
 
Q