I made a very simply framework with the following type:
public struct Foo {
public init(bar name: String) { }
public init(foo name: String) { }
public init(foo val: Int) { }
}
I have a corresponding DocC landing page:
# ``Test``
A test framework.
## Overview
Overview of the test framework.
## Topics
### Essentials
- ``Foo``
- ``Foo/init(bar:)``
The landing page shows up when I build documentation. So far so good. But when I try to add either of the other two init(foo:) initializers...
Looks like it's going to work! But, no...
The disambiguation suffix does not appear. Trying again by hitting escape...
Again, looks like it should work, but no suffix is added. Of course building the documentation at this point gives me a Topic reference 'Foo/init(foo:)' couldn't be resolved. No local documentation matches this reference. Which is pretty confusing because the error is resulting not from "no matches", but from multiple disambiguated matches.
Is this an Xcode bug? If so, is there a workaround?
I did discover a workaround, which is to build the documentation, then use the documentation browser to export a .doccarchive bundle, then go spelunking in the bundle:
Yes, it looks like a bug that Xcode doesn't insert the necessary disambiguation when providing link completion.
IIRC bugs in Xcode are considered "off topic" for this forum but if you report a feedback (at https://feedbackassistant.apple.com) and post the feedback number in this thread I can make sure that it reaches the right people.
I'm not aware of a good workaround. The best I could think of would only improve the error message—making it easier to find the missing disambiguations—but Xcode still wouldn't add the necessary disambiguation when providing link completion and it would require a newer toolchain than what's included in Xcode 14.2.
We have been working on a new experimental link resolution implementation in Swift-DocC but that code is only available in the Swift 5.8 toolchain and later (the Development toolchain). With one of those toolchains (from Swift.org - Download Swift) you could opt-in to the new link resolver implementation by setting this user default:
I haven't had the chance to try out @ronnqvist new capabilities - but as a temporary workaround, I found half the battle was determining what the possible identifiers were. Fortunately, this can be relatively easily extracted, and I keep a script handy to do just that.
I include --emit-digest in the building of an archive (or set of HTML pages), and then dig around in the file linkable-entities.json within the archive.
This identifiers include the disambiguation hashes (even if my example doesn't show that immediately), which at least gives you a range of options to try.
For my part, I generate this giant list of symbols and dump them all together in a sorted list to make it a bit easier to start to sort and organize (curate in DocC speak) the symbols within documentation pages.