macdevcenter.com
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button

Easy Code Documentation with Xcode
Pages: 1, 2, 3

Add Documentation to Xcode Project

Our last steps resulted in a set of HTML pages that provide some documentation of our project. The HTML was saved in a folder in our project directory. To make the documentation easy to access, let's add it to our Xcode project.



  1. Right-click (or Ctrl-click) on the PathDemo group in the left pane of your Xcode project and choose Add -> New Group.

    Right-click (or Ctrl-click) on the PathDemo group in the left pane of your Xcode project and choose Add -> New Group.
  2. Rename your new group Documentation.

  3. Right-click (or Ctrl-click) on the Documentation group and select Add -> Existing Files.

  4. In your PathDemo project folder, find the html folder. In that folder, select the file index.html.

  5. Now there is a convenient link to your documentation that you directly access from within your project. However, it might show the HTML code rather than the rendered web page when you click on the file. We can change this behavior in the Xcode preferences.

  6. Choose Preferences from the Xcode menu.

  7. Switch to the File Types tab, and find the text.html settings under the file/text group. Choose HTML File as the preferred editor and click on OK.

  8. You may need to close and reopen your project to get the documentation to render as HTML. When you do, spend some time exploring what is there.

What we have at this point is documentation that lists every method and variable from our classes. We have not created any special descriptions; so far everything has been automatic. We even added the documentation to your project so that you do not have to launch a web browser to read the documentation.

Making It Automatic

Right now it isn't too hard to update the documentation if our code changes. We can simply press Start in the Doxygen user interface. However, it would be nice if we could skip this step. We can do that by adding a step to our build process. That way, the documentation will be updated every time we build the project in Xcode. This is possible because Doxygen can run from the command line as well as from the GUI.

  1. Expand the Target group in the left pane of Xcode.

  2. Right-click on the PathDemo target and choose Add -> New Build Phase -> New Shell Script Build Phase.

    Right-click on the PathDemo target and choose Add -> New Build Phase -> New Shell Script Build Phase.
  3. Type the following into the Script text field: /Applications/Doxygen.app/Contents/Resources/doxygen Doxyfile

    This is a very simple script! All you are doing is calling the Doxygen program with the Doxyfile configuration as input. When you use the Doxygen user interface to change the configuration and save the changes to this file, the changes will be seen the next time you build the project.

    Close the Shell Script Info pane when you are done with it.

    Close the Shell Script Info pane when you are done with it.

Pages: 1, 2, 3

Next Pagearrow