Can I generate a docc archive directly from Package.swift?

If the library I want to document is primarily tracked with a Package.swift cross-platform definition, what's the optimal way to build and render documentation?

Can I still use xcodebuild docbuild with the Package.swift format for the project, or does the documentation system require a fully-defined Xcode project wrapped around it?

Or do I need to open the Package.swift file in Xcode and then generate the docc archive from Xcode's Product menu?

Answered by Documentation Engineer in 677760022

xcodebuild docbuild still works with a Package.swift file. You'll need to add a -scheme argument to tell xcodebuild which target to build; you can run xcodebuild -list to see the list. For example, you can run xcodebuild docbuild -scheme MyPackage to build a DocC Archive for the MyPackage scheme. The archive bundle will appear in your Derived Data directory (for example, ~/Library/Developer/Xcode/DerivedData/MyPackage-[hash]/Build/Products/Debug/MyPackage.doccarchive).

Accepted Answer

xcodebuild docbuild still works with a Package.swift file. You'll need to add a -scheme argument to tell xcodebuild which target to build; you can run xcodebuild -list to see the list. For example, you can run xcodebuild docbuild -scheme MyPackage to build a DocC Archive for the MyPackage scheme. The archive bundle will appear in your Derived Data directory (for example, ~/Library/Developer/Xcode/DerivedData/MyPackage-[hash]/Build/Products/Debug/MyPackage.doccarchive).

Can I generate a docc archive directly from Package.swift?
 
 
Q