Introduction
If you are like me – beginning with programming in Objective-C in Xcode and you were Java programmer previously, you will wonder how to write code comments in a similar way to JavaDoc.
Well, Apple obviously thinks that programmers do not need to write documentation. Otherwise they would implement a similar documentation tool such as Javadoc and do not force programmers to do nasty hacks to be able to do so.
However there is a way, even though it requires a few manual steps. This blog post is a step-by-step how-to guide to prepare your Mac OS X 10.7 and Xcode 4.3 to be able to generate documentation out of your code and let Xcode offer that documentation to you through its Organiser and also through Quick Help in Utilities area.

Xcode 4 Quick Help
Prepare the Appledoc application
We will need to build the Appledoc application as there is no official OS X package available. After having the binary builded we will need to distribute the binary and also a couple of templates required to build HTML documentation files into our system.
Check out the Appledoc web
Walk through Gentle Bytes website. We will use this free tool (BSD license) to generate documentation out of our source files.
Syntax of the code comments is described on Gentle Bytes comments page.
Clone github repository
We need to download the application in order to build it. Go into the directory where you hold Xcode projects and then type following command in Termial application:
git clone git://github.com/tomaz/appledoc.git
This command will create appledoc directory and clone the project’s GIT repo there.
Build the application
Open the appledoc.xcodeproj file in Xcode.
Edit your Scheme by clicking Xcode menu > Product > Edit Scheme menu item (Cmd + <) and change the Build Configuration to Release.
Build the project to get an executable binary.
Install the aplication
Let Xcode open the location of built appledoc executable.
You can also find the location manually, just search in ~/Library/Developer/Xcode/DerivedData/ for appledoc directory with some randomly-generated suffix. Copy the appledoc executable into the /Applications directory. Having the executable in the /Applications directory will allow Xcode to run the tool as a build script.
Prepare documentation templates for use
Appledoc application requires a couple of templates to be able to generate Xcode documentation. Goto the appledoc directory (the one created by GIT in previous step) and copy the content of Templates sub-directory into ~/Library/Application Support/appledoc/. This is the default location the application searches for its templates in.

Appledoc templates
Configure your project
To ease our life we will configure our Xcode projects so that when we build our applications the documentation will be generated automatically as well as Xcode will be informed that the documentation was updated.
Create configuration file
Add this configuration file into your Xcode project directory and name it AppledocSettings.plist. Do not forget to change the red-marked options according to your needs. You can also play with the other options as well. More information can be found on the Gentle Bytes settings page.
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict>
<key>--company-id</key>
<string>com.yourcompanysite</string>
<key>--create-docset</key>
<true/>
<key>--ignore</key>
<array>
<string>ThirdParty</string>
<string>Libraries</string>
<string>Frameworks</string>
<string>Testing</string>
</array>
<key>--install-docset</key>
<true/>
<key>--docset-platform-family</key>
<string>macosx</string>
<key>--output</key>
<string>/tmp</string>
<key>--project-company</key>
<string>YourCompanyName</string>
<key>--project-name</key>
<string>YourProjectName</string>
<key>--project-version</key>
<string>YourDocumentationVersion</string>
<key>--keep-undocumented-objects</key>
<true/>
<key>--keep-undocumented-members</key>
<true/>
<key>--warn-undocumented-object</key>
<false/>
<key>--warn-undocumented-member</key>
<false/>
<key>--warn-empty-description</key>
<true/>
<key>--warn-missing-arg</key>
<true/>
<key>--warn-unknown-directive</key>
<true/>
<key>--logformat</key>
<string>xcode</string>
<key>--exit-threshold</key>
<integer>2</integer>
</dict>
</plist>
Create documentation target
Add a new target into your Xcode project (Mac OS X/Other/Aggregate target) and name it Documentation. The new target will allow us to get the documentation generated every time we build our projects.

Aggregate target
Add new Run Script
Add Run Script build phase into the Documentation target. The Run Script will give us a chance to enter shell script to run the Appledoc application and pass commands over to it.

Adding Run Script Build Phase
Configure Run Script
Add the shell script below into the Run Script shell command place.
# Build an Xcode documentation /Applications/appledoc "$SOURCE_ROOT/$PROJECT_NAME"
Set up the build scheme
Add Documentation target into the existing scheme so that the documentation is created every time you build your project. You can reach the screen below by clicking Xcode menu > Product > Edit Scheme menu item (Cmd + <).
Enjoy 🙂
Every time you will build your project the documentation will be generated automatically and will be pushed to Xcode so you can start using your documentation immediately.
The only issue with Xcode 4 is it does not reload Quick Help cache upon documentation changes. The only way to get it reloaded is to restart Xcode. In Xcode 3, it was possible to reload the documentation by running an AppleScript command below. However, it does not work in Xcode 4 anymore.
tell application "Xcode" load documentation set with path "/Users/YourUserName/Library/Developer/Shared/Documentation/DocSets/ com.yourcompanysite.YourProjectName.docset" end tell
If you are interested to see the output documentation files the Appledoc tool creates, go to the directory below.
~/Library/Developer/Shared/Documentation/DocSets/
Posted by dmi3j on July 13, 2011 at 10:35 am
I think AppledocSettings.plist is broken. Could you fix this one, please?
Posted by Pavel Lobodinský on July 13, 2011 at 8:24 pm
Thanks Dmitrij for your comment. The XML is corrected now.
Posted by Abhilash Vijayakumar on February 23, 2012 at 2:31 am
Hi i think this is a good project. Got build errors on Xcode 4.2
Use of undeclared identifier ‘NSRegularExpression’
Any suggestion ?
Posted by Pavel Lobodinský on February 29, 2012 at 6:15 pm
I have no idea what that problem means. Sounds to me the like a bug in Appledoc implementation.
Posted by Tom on March 1, 2012 at 9:28 am
Hey, I’m the person behind appledoc, just came accross this post searching for custom build targets 🙂 I find it nice introduction to appledoc and will add it to home page along other external links. Thanks!
BTW The incompatibility error described above is due to using NSRegularExpression which are 10.7 only. These were introduced with recent contribution that allows better headerdoc integration. It should be fixed by now, update to latest version. The downside is the feature is disabled for 10.6.
Posted by lobodpav on March 1, 2012 at 3:55 pm
Great to hear I have done something useful! It is the first time an author of a tool adds my humble post to his home page 🙂
Posted by Documenting Objective-C Code using AppleDoc | Mobile Product Development on April 16, 2012 at 1:28 pm
[…] This post shows you how to set up AppleDoc, and how to integrate with the build process to keep your documentation up-to-date: Documenting you code in Xcode 4 […]
Posted by odpadnem on April 21, 2012 at 11:04 am
Hi,
I’m having this error in Xcode 4.3.2 when trying to build:
ERROR: AppledocException: –project-name argument or global setting is required!
but, I have those variables set in AppledocSettings.plist. Any idea what causes this error?
Thanks for any suggestions.
Posted by odpadnem on April 21, 2012 at 11:31 am
I have just fixed it.
chaged
/Applications/appledoc $SOURCE_ROOT
to
/Applications/appledoc $SRCROOT/$PROJECT_NAME/AppledocSettings.plist $SOURCE_ROOT
Posted by lobodpav on April 22, 2012 at 1:04 pm
Thanks for posting the solution!
Posted by Mark Richard Danks (@defragged) on May 22, 2012 at 6:22 pm
Thanks for the article. As a possible improvement, you might want to change the shell script to be:
appledoc –logformat=xcode $SOURCE_ROOT
By specifying the Xcode-specific log format, Xcode can show the warnings and errors it discovers when building the documentation in the issue navigator. You can also add that to the AppledocSettings.plist, but I prefer to leave it out so manual command line builds don’t use that style.
Posted by lobodpav on May 22, 2012 at 10:03 pm
Well, thanks for your comment! It is great to get Xcode showing build issues. Will try this out as soon as I have a chance. Thanks again.
Posted by elendil on May 25, 2012 at 11:47 pm
Following the directions given here, I can get the documentation to show up in the xcode doc browser, but I can’t get it to show anything in the xcode quick help window, which is really annoying.
I do something along the lines of (foo is a member function)
/**
* blah blah blah
*/
-(void) foo {}
Should I document in a special way to get the information to the quick help window? I notice that apple content has an “abstraction” field in the quick help window, where most of the text is displayed.
Posted by lobodpav on May 26, 2012 at 12:15 pm
I have update the blog so that the links to Gentle Bytes sites work again.
Yes, the comments have to have a special format, very similar to JavaDoc. See http://gentlebytes.com/appledoc-docs-comments/
Posted by lobodpav on May 26, 2012 at 12:22 pm
An example:
/**
* Blah blah blah
* @param str Foolish parameter
* @return Useful array
*/
-(NSArray *) foo:(NSString *)str {}
Posted by elendil on May 26, 2012 at 4:33 pm
Still, copying your example doesn’t show anything in the quick help window.
All it states is:
“Name: foo:
Declared in: GraphViewController.mm”
Posted by Pavel Lobodinský on May 27, 2012 at 8:01 am
Let me get back to you. I need to do some research on that.
In the latest Xcode version 4.3 it really does not work. The documentation gets generated, though. Xcode just does not display it.
Posted by elendil on May 27, 2012 at 11:54 am
Yeah, that’s my understanding as well. I can see it in the documentation browser (is that what it’s called?), but the real (well, the only, actually) reason for me to install and use appledoc (short term, anyway) is to see my documentation in the quick help window.
Thanks for the help so far. No rush, I have plenty of other stuff to attend to meanwhile.
Posted by Pavel Lobodinský on May 27, 2012 at 7:08 pm
It’s called Documentation Organiser, but that’s not important 🙂
Why is your usage of appledoc just a short term matter?
Posted by Pavel Lobodinský on May 27, 2012 at 8:47 pm
I was not able to fix this issue. Therefore, I have submitted a question here: https://groups.google.com/forum/#!topic/appledoc/XxfnA97ezho
Posted by elendil on May 28, 2012 at 9:07 am
It wasn’t my intention to belittle appledoc in any way.
I’ve been using the quick help window a lot to see the contents of structs and such, and it annoyed me that I had to shuffle through my files to read the documentation on my own code.
I’d rather shuffle through the code than wade through the documentation organizer (thanks), so I really just need the quick help window functionality. For now, that is.
I’ve always documented and I still do, so it’s not a matter of getting things documented. It’s just a matter of getting the documentation to show when I need it.
Your question for the google groups words my problem nicely, btw.
Posted by elendil on May 28, 2012 at 9:07 am
Oh, and it turns out that I’m a lousy blog user. I keep forgetting to press reply to the post I’m answering, instead of just using the box at the bottom.
Sorry.
Posted by Pavel Lobodinský on June 9, 2012 at 10:47 pm
I solved the issue myself. Just add
<key>–docset-platform-family</key>
<string>macosx</string>
into your AppledocSettings.plist. Xcode 4.3 seems to check this against the platform your code is being developed for.
Also, I have updated the blog.
Posted by Pavel Lobodinský on May 28, 2012 at 9:13 am
No problemo 🙂 Let’s see if the autor replies. I’ve been using Quick Help a lot as well so it’s a pity it does not work anymore.
Posted by kashif on June 22, 2012 at 3:34 pm
I have successfully integrate appledoc in my xcode 4.2 . i used following comments:
/** @name Section title */
/** Method description */
– (void)someMethod;
After succesfully build of my project, i donot see any documentation any where on my macbook 😦 . I have set company id as com.amathon. I have “/Users/macbook/Library/Developer/Shared/Documentation/DocSets” but there is no filder com.amathon.docs .
Please help me out.
Posted by Pavel Lobodinský on June 25, 2012 at 9:28 am
In that case you were not successful to integrate it 🙂
The result of runnin appledoc in your Xcode project is the docset in the folder you mention in your post. It this was not created, then the build had to fail.
Did you get any error messages?
Posted by kashif on June 25, 2012 at 9:54 am
Thanks for your reply.
I have not got build errors, and my project got successfully build.
I have added new aggregate target as ‘Documentation’ and in Documentation shell command i have written “/Applications/appledoc /GIT-Projects/myProject/AppledocSettings.plist /Developer4” .
my appledoc executable file is in /usr/bin and also in Applications folder.
I have copied templates subdirectories in /Library/Application Support/appledoc/Templates
Please help me out.
Posted by Pavel Lobodinský on June 26, 2012 at 3:16 pm
I am not sure what the /Developer4 folder contains but the syntax shall be similar to this:
/Applications/appledoc /GIT-Projects/myProject/AppledocSettings.plist /GIT-Projects/myProject/
Try to run this command in commandline to see what happens. If everything goes well, there is no output but “appledoc version: 2.0.5 (build 789)”. After running the command above you shall have the docset in your ~/Library/Developer/Shared/Documentation/DocSets/ folder.
Posted by kashif on July 3, 2012 at 10:11 am
I have successfully generated appledocs in xcode 4.2, but i was unable to refresh documentation again. Xcode still show old documentation. I have read from different form to run tell application “xcode” action script but i donot know where i have to place that action script? Do i need to place it just below the “/Applications/appledoc $SOURCE_ROOT/$PROJECT_NAME” ??
Please help me out.
Thanks
Posted by Pavel Lobodinský on July 4, 2012 at 9:23 am
The script works in XCode 3 only. It does not work in version 4 anymore. In order to refresh the documentation after it is built you have to restart Xcode.
Posted by kashif on July 4, 2012 at 9:37 am
I have restart Xcode even 2,3 times. Actually i have generated documentation with 50 classes in it. Documentation generated very fine. Now i have removed some unused classes and now my classes are 45 in number. Now when i generate documentation then old 5 classes documentation still shows in Xcode 4.2 > Orginizer > Documentation tab.
I want to remove old documentation of that 5 classes.
Any other interesting thing is that i have restart Xcode and new documentation has updated documentation in it, but why it show 5 old file documentation as well . 😦
Posted by Pavel Lobodinský on July 4, 2012 at 9:42 am
Sounds to me as a bug in appledoc software. It looks like it does not remove the old files prior generation of the new docset.
You can file a bug here: https://github.com/tomaz/appledoc/issues
Posted by kashif on July 4, 2012 at 9:58 am
Hmmm, well thanks lobodpav.
Posted by Pavel Lobodinský on July 4, 2012 at 10:11 am
You are welcome, always glad to help.
Posted by giupo777 on September 4, 2012 at 10:52 pm
I owe you a beer! Thank you!
Posted by Pavel Lobodinský on September 5, 2012 at 7:24 am
Depends on where you are from 🙂
Posted by VIctor Solorio (@PinkySolorio) on January 3, 2013 at 4:36 pm
Hi, great post.
Does this work for iPhone projects?
Posted by Pavel Lobodinský on January 3, 2013 at 5:41 pm
Hi and thanks.
I have not tested appledoc on iPhone projects. But I think it should work with no issues. It is just a different Xcode project with ObjC code.
Posted by Theresa on January 25, 2013 at 11:43 pm
Thanks for this great post!
One quick question, I set –create-html to be ‘YES’ in the AppledocSettings.plist, but cannot locate the html output. Could you please advise?
Posted by Pavel Lobodinský on January 27, 2013 at 1:38 pm
You will find the HTML code in this folder: ~/Library/Developer/Shared/Documentation/DocSets/com.yourCompanySite.YourProjectName/Contents/Resources/Documents/ .
By the way, –create-html option is set to true by default. You do not need to set it explicitly. It is useful if you want to check your appledoc settings. If you invoke appledoc with –no-create-html, appledoc will validate your settings without generating the HTML output. It is just a time saver – HTML generation takes about 90% of the whole processing time.
Posted by Ramani on February 25, 2013 at 2:06 pm
HI, please specify the path for run script in xcode4.5
Posted by Ramani on February 25, 2013 at 2:43 pm
Please reply soon.
Posted by Anonymous on February 25, 2013 at 3:38 pm
Firstly, I have no idea which path do you mean. Do you talk about the location where this tool generates the documentation files?
Secondly, I will not have time to get into this sooner than during this weekend. Sorry, I am not an official support for the tool 😉
Posted by Ramani on February 26, 2013 at 9:44 am
HI, I am talking about the following script which is not being supported in xcode 4.5 , please help me: /Applications/appledoc “$SOURCE_ROOT/$PROJECT_NAME”
Posted by Anonymous on February 26, 2013 at 9:46 am
I see. Let me get into that and come back during this weekend. I am currently snowed under my work issues.
Posted by Pavel Lobodinský on March 2, 2013 at 10:18 am
Just built the latest appledoc version from GIT and tried it in Xcode 4.6. It works perfectly.
What error message do you get? You need to be more specific so I am able to help.
Posted by Kirow on March 10, 2013 at 3:08 pm
Is it possible to update quick help without restarting Xcode? (using xcode 4.6, quick help do not appear until i restart app)
Posted by Pavel Lobodinský on March 10, 2013 at 6:55 pm
It did not work in older Xcode versions either and I did not find a way to eliminate Xcode restart 😦
Posted by Zaldy on March 14, 2013 at 10:53 am
Hello,
Thank you for posting this. This is very helpful.
By the way, for those who encountered a problem below, I might have something to help.
ERROR: AppledocException: –project-name argument or global setting is required!
—————–
This problem has something to do with where your AppledocSettings.plist is located and its filename which is case-sensitive. In RunScript -> /Applications/appledoc “$SOURCE_ROOT/$PROJECT_NAME”, it assumes that your AppledocSettings.plist is located within the folder with the name same with your Project Name.
MyProject/AppledocSettings.plist
If for any case you added the AppledocSettings.plist inside a folder named “AppleDoc”, your Runsript should now be:
/Applications/appledoc “$SOURCE_ROOT/$PROJECT_NAME/AppleDoc”
Hope that helps.
Thank you again for this wonderful post.
Posted by Pavel Lobodinský on March 14, 2013 at 11:22 am
Glad you like it. Happy documenting in Xcode 🙂
And thanks for posting your findings about the plist file!
Posted by Diego A. Rincon on February 25, 2014 at 10:23 am
This post is extremely useful. Thank you for taking the time to put everything together.
I have a quick question. Appledoc only documents files located in the same directory as AppledocSettings.plist and its subdirectories. How can I document files located in a different folder? Is there any setting where I can include something like “../MyNewFolder”?
Thank you in advance for your help
Posted by Pavel Lobodinský on February 25, 2014 at 10:59 am
As per my understanding, the AppledocSessings.plist specifies global options for your project so that you do not have to pass tons of command line arguments to the appledoc script.
Once having the options file in place, just call appledoc and pass it list of paths you want to generate documentation for. I.e. update your Run Script command in the Documentation target and Bob’s your uncle.
Updated script from this tutorial: /Applications/appledoc “$SOURCE_ROOT/$PROJECT_NAME” “../MyNewFolder”
Posted by Diego A. Rincon on February 25, 2014 at 11:24 am
Thank you! This is exactly what I was looking for
Posted by enabujik@gmail.com on December 17, 2014 at 11:39 am
very nice