cocoaxcode4help-viewerapple-help

Anchors in help-book not working


I've double checked everything and hoping someone can find a stupid mistake that I'm not seeing.

I'm trying to build a Apple Help section for my application and it correctly goes to the landing page however none of the anchors work. The landing page is called index.html and the other page is called test.html which is located in the pgs directory.

In index.html I have:

<a href="help:anchor=support bookID=com.company.app_name.help">Link to another page</a>

In test.html I have:

<a name="support"></a>

So here's the steps that I followed in order to get to where I am right now:

1) I built the directory as specified by the Apple documentation

AppName.help/
    Contents/
        Info.plist
        Resources/
            shrd/
            English.lproj/
                index.html
                search.helpindex
                pgs/
                    test.html

2) I built the Help Info.plist as specified in the Apple documentation. Included in the Info.plist I set the CFBundleIdentifier to com.company.app_name.help.

3) In my app Info.plist I set the CFBundleHelpBookFolder to AppName.help and set CFBundleHelpBookName to com.company.app_name.help

4) I then copied the directory that I built into Xcode while ensuring that I selected the option Create Folder References for any added folders.

5) Then I used Help Indexer to index the directory AppName.help. Making sure that I select the option to Index anchor information in all files.I then copied the .helpindex file to the English.lproj folder where it's supposed to be.

That's it. There's a couple of things that I noticed about my application if I place the following link in the index.html file it works correctly.

<a href="pgs/test.html">Click this link</a>                 

Also here is my code for the index.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>AppName Help</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="robots" content="noindex" />
    <meta name="AppleTitle" content="AppName Help" />
    <meta name="AppleIcon" content="../shrd/icon.png" />
</head>
<body>
    <a href="help:anchor=support bookID=com.company.app_name.help">Link to another page</a>
</body>

Here is the code for the test.html.

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Testing Links</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="robots" content="anchors" />
    </head>
    <body>
        <a name="support"></a>Does linking work?<br/>

    </body>
</html>

Here is the Info.plist for my Help file.

<?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>CFBundleDevelopmentRegion</key>
    <string>en_us</string>
    <key>CFBundleIdentifier</key>
    <string>com.company.app_name.help</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>AppName</string>
    <key>CFBundlePackageType</key>
    <string>BNDL</string>
    <key>CFBundleShortVersionString</key>
    <string>2</string>
    <key>CFBundleSignature</key>
    <string>hbwr</string>
    <key>CFBundleVersion</key>
    <string>2</string>
    <key>CFBundleHelpBookName</key>
    <string>AppName Help</string>
    <key>HPDBookAccessPath</key>
    <string>index.html</string>
    <key>HPDBookIconPath</key>
    <string>shrd/icon.png</string>
    <key>HPDBookIndexPath</key>
    <string>search.helpindex</string>
    <key>HPDBookKBProduct</key>
    <string>app_name1</string>
    <key>HPDBookKBURL</key>
    <string>http://www.company.com</string>
    <key>HPDBookRemoteURL</key>
    <string>http://www.company.com</string>
    <key>HPDBookTitle</key>
    <string>AppName Help</string>
    <key>HPDBookType</key>
    <string>3</string>
</dict>
</plist>

Also I followed this post:http://www.cocoabuilder.com/archive/cocoa/312037-updating-an-app-help.html to clear out the cache every time I make a change in addition to re-indexing the directory.

Thanks all!


Solution

  • Sure David, Thanks for the reminder.

    From what I recall and my sloppy documentation I run the following command to index the help documentation files:

    hiutil -vCaf ./search.helpindex English.lproj
    

    However one thing that I realized is the index utility will complain any time the &nbsp; character is used. Instead substitute the character &#32;

    I think that was the bug in my case.