As part of some recent testing for Alfresco Mobile 1.4 (1.4.1 is currently being reviewed by Apple), I noticed that my thumbnails and document previews had stopped working. All this probably coincided with an upgrade to OS X 10.8.2, JDK 7 and/or the phases of the moon - whatever it was it's time to fix it!
Previously I'd tried both MacPorts and Fink to install command line utilities, but these two projects seem to either be far too complex, or rarely up-to-date. Fortunately there's a new kid on the block, namely Homebrew. Built upon Ruby and git and some very sensible deployment choices (binaries are linked into your path, rather than installed there) it sounds like exactly what I needed to fix my development setup.
The first step is to ensure there's a good GCC compiler installed locally. If you happen to be running Xcode already, that's just a matter of choosing the optional 'Command Line Tools' component in Preferences / Downloads. There are probably many different ways of getting GCC installed, but Xcode would be the simplest, if perhaps not the most efficient disk space-wise. Anyway, now you've got Xcode installed there's nothing stopping you modifying and contributing to the Alfresco iOS Mobile source code -- so that's the option I'm going to recommend!
The next step is to install Homebrew itself; very simple by copy & pasting the command line:
Homebrew packages are simply installed using 'brew install <package>'. Each package is scripted in such a way to download and install any mandatory dependencies. The Homebrew ethos is to not install any unnecessary cruft, so we'll have to bear that in mind when installing the packages Alfresco needs for transformations.
I've already got a local install of Apache OpenOffice, so just need to install: ImageMagick, Ghostscript and swftools. Ghostscript can be installed as an optional submodule of ImageMagick, so that's the first package:
$ pdf2swf --version -bash: pdf2swf: command not found
Hmmm.. what's going on here? A little Googling concludes that I'll need to manually install a few dependencies, as pdf2swf is actually an optional component within the swftools suite, so let's uninstall swftools and install the dependencies:
Now we're good to go with swftools again, and this time should get pdf2swf too:
$ brew install swftools
$ pdf2swf --version pdf2swf - part of swftools 0.9.2
OK, so that was a little long-winded, but pretty easy overall.
But we're not quite done yet. OS X has its own version of the infamous Windows so-called 'DLL Hell' regarding .dylib files. The problem here involves the ImageIO system framework located at /System/Library/Frameworks/ImageIO.framework. It's evident when firing up the Alfresco Repository, as we'll start to see some transformation errors during bootstrap:
err: dyld: Symbol not found: __cg_jpeg_resync_to_restart Referenced from: /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib Expected in: /usr/local/lib/libjpeg.8.dylib
Fortunately it's simple to fix, helped in part by the fact that Homebrew links binaries and libraries. We'll just need to re-link some image dylib files back to the ImageIO framework package, remembering to remove the problematic links first: