Tuesday, September 18, 2012

Working around broken hiutil in Mountain Lion

Note: This blog is deprecated. @synthesize zach has moved to a new home, at zpasternack.org. This blog entry can be found on the new blog here. Please update your links.

For VideoBuffet, I use VoodooPad to author my help file. I learned about doing this from this blog post, and it's been working well for me. Until the last VideoBuffet update, when suddenly my help anchors stopped working.

As the article states, you basically make a Run Script build phase in Xcode which exports the VoodooPad doc as HTML. Then, your VoodooPad doc is setup to run Apple's help indexer (hiutil) to create the index. What the article doesn't tell you is how to open your help to a particular page.

To do this, in VoodooPad you make an alias to the page to which you want to link, and give it a name (in the title bar, click Info; then, under Aliases, click the + button and type the name). The screenshot below shows VideoBuffet's Preferences page, and you can see I've made an alias called "preferences".

VoodooPad screenshot

Finally, in code (like, in the Help button in the Preferences dialog), you can do this:

    NSString *locBookName = [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleHelpBookName"];
    [[NSHelpManager sharedHelpManager] openHelpAnchor:@"preferences" inBook:locBookName];

…and the appropriate page will open up in Help Viewer. It works great, and I use this technique all over the place.

Back to the point. While testing VideoBuffet 1.0.3, I discovered that the help links were all broken. After a bit of hair-pulling I finally figured out that hiutil was giving me errors, and ending up not creating a proper index (it wasn't getting as far as my anchors). After Googling it, to no avail, I posted a question on Stackoverflow, which, at the time of this writing still has no responses. If you know the answer, by all means, post it there. :)

I've since discovered that the version of hiutil that ships with Mountain Lion (version 1.3) was where this problem started showing up, and the version from Lion (1.2) works as it always did. So, my (terrible) workaround: use the version of hiutil which shipped in Lion. Find yourself a Lion system, and copy /usr/bin/hiutil to the machine where you do your builds. I didn't want to replace the newer hiutil, so I called the Lion copy hiutil_old, and changed the VoodooPad export script to use that one. There's one other step: hiutil 1.2 depends on MPWXmlCore.framework, which no longer exists in Mountain Lion. So in order to use hiutil 1.2 on Mountain Lion, you need to copy MPWXmlCore.framework from a Lion system as well (it's in /System/Library/PrivateFrameworks/).

3 comments:

  1. Kudos, that was helpful! Thanks

    ReplyDelete
  2. Hi zpasternack,
    I have just been searching for info about this topic for a while and yours is the best I have found out so far.




    broken iPhone

    ReplyDelete
  3. Lucky 15 Casino - Mapyro
    This 화성 출장안마 casino is owned by Pragmatic 강원도 출장마사지 Play Limited and 동두천 출장샵 has a total of 30000 slot 삼척 출장샵 machines available. Find details on each slot 의왕 출장샵 game you will find.

    ReplyDelete