Is there a way to link Swift source code as Xcode document?

I expect that when I click "Jump to Definition", I can view Swift core lib source code, not the document of interfaces.
Is there any way to realize this?

This isn't supported today, however, I love that idea! It would help with the workflow where you build and browse documentation for your framework locally. If compilers could provide the source location of API declarations, DocC could potentially surface that to users in some way.

There are interesting challenges for such a feature however, such as:

  • What experience can be provided if you don't have access to the source documentation, because you've opened a DocC archive that someone else built and sent you?
  • What if you do have the project's sources, but the DocC archive you opened were built using a different version of the sources, where some APIs might have moved, or changed source locations?
  • Where would DocC record information about the source location of symbols, and how do we maintain privacy for closed-source projects? For example, if I maintain a closed-source project, I wouldn't want to leak the organisation of my source files in my DocC archives.

Another way to approach this problem would be to expect IDEs some ability of reconciling a page's doc URL back to its declaration without additional metadata provided by DocC. This would provide the added benefit that if an API's declaration changes source location, jumping back to the API's source would still land you at the right spot.

1 Like