Generating extension docs in Xcode?

Any way to get DocC to generate documentation for extensions I’ve made? I have this, for example:

extension
Int
{
	/**
		Renders a unicode-superscript version of the integer.
		
		1234 -> ¹²³⁴
		-1234 -> ⁻¹²³⁴
	*/
	
	public
	var
	superscriptString: String
	{
		var s = …
		return s
	}
}

But building the docs with Xcode just ignores it. My understanding is there’s a switch for docc proper, but I don’t know how to set that up in Xcode (version 26.1).

And honestly, I don’t know why it’s off by default.

Hey Rick,

I just cobbled up a quick example in Package.swift and built the content in Xcode, and the extensions show up and are included. Here's a quick screenshot of my "dummy project" and it's contents - including an extension modeled loosely after your example (but which doesn't do anything)

Are you trying to view this within Xcode? generate an archive that you're hosted somewhere else?

I'm not quite sure I understood what's "disabled by default" there

(This was with the just-released Xcode 26.2, if that makes any difference)

2 Likes

Well, I don’t know why I wasn’t seeing it before, but it is indeed building all of my documentation. When I had this issue a while back, I was told that by default, it didn’t build documentation for extensions. Either that was false, or it has changed, and that misunderstanding, combined with my inability to see, made me think it wasn’t working properly.

Thanks for forcing me to take a closer look!

1 Like