Adding inline documentation to your Xcode project

Yep, that’s the most abandoned thing during the development, I know.

But it is so easy to add documentation comment blocks to your code, either in Swift or Objective-C, that there won’t be an excuse to do so… At least not after you read this blog post.

There is already a keyboard shortcut: option(alt) + cmd + / in Xcode to insert documentation.

If you put your cursor one line above the property, or method and press the option + command + /, the inserted comment block will be generated complies with the Xcode documentation (HeaderDoc or DoxyGen). That means the you can see it in the popups when you option+click on the entity, like it is with Apple provided classes. You might need to rebuild (command + B) the project to the changes take effect.

adding_documentation_shortcut

You can find further, and very comprehensive information about the documentation options can be used in your code here: https://www.appcoda.com/documenting-source-code-in-xcode/


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.