How hard could it be? There must be plenty of people who are using the QT cross-platform graphical user interface toolkit to create Mac applications... right?
With some help and hints and a lot of googling I did finally succeed, but not before giving up at least three separate times. I'm writing this to, hopefully, save somebody else lots of frustration.
Side note: Bitcoin-Qt doesn't run on PowerPC chips, doesn't use more than 4 gigabytes of memory, and doesn't contain any CPU-performance-critical code. So there is no reason to create and deploy a "universal" app bundle, and I saved myself a lot of recompiling time by compiling just 32-bit i386.
Problem 1: I've got a 64-bit Mac running Snow Leopard (10.6).
Solution 1: compile everything with these flags:
-mmacosx-version-min=10.5 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk
Compiling Bitcoin-Qt with those flags is easy when you know how; just add something like this to the Bitcoin-Qt.pro file:
macx:QMAKE_CXXFLAGS += -mmacosx-version-min=10.5 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk
Problem 1a: I'm using macports for dependencies, so it wasn't obvious how to compile everything with those flags.
Solution 1a: Edit /opt/local/etc/macports/macports.conf and set macosx_deployment_target and the build_arch:
# Building for lowest-common denominator OSX 10.5, 32-bit # (see build_arch i386 later in this file) macosx_deployment_target 10.5 # CPU architecture to compile for. Defaults to i386 or ppc on Mac OS X 10.5 # and earlier, depending on the CPU type detected at runtime. On Mac OS X 10.6 # the default is x86_64 if the CPU supports it, i386 otherwise. # GAVIN: overrode to default to 32-bit i386 build build_arch i386I then ran:
port list installed | cut -f 1 -d' ' | uniq > /tmp/portsinstalled sudo port remove installed sudo port install $(cat /tmp/portsinstalled)... to remove and recompile/reinstall everything. Yes, that took several hours.
Problem 2: macdeployqt refuses to deploy one of our dependencies.
Solution 2: file a bug (QT-21913), and patch my copy of macdeployqt.
How'd I patch? I found the macdeployqt source inside /opt/local/var/macports/build/ (find /opt/local/var/macports/build -name macdeployqt -print), copied it to $HOME/src/, and ran qmake/make to compile after editing its .cpp files.
Problem 3: macdeployqt created an App bundle that crashed on startup.
Solution 3: When you 'port install qt4-mac', it installs a shared-library version of Qt. macdeployqt seems to work with a shared-library version of Qt... but it really doesn't. It wants the 'Framework' version. So the solution: 'port deactivate qt4-mac' then 'port install qt4-mac +framework'.
Problem 4: Images were not being displayed by the deployed App.
Solution 4: macdeployqt wasn't deploying plugins and the images are JPEG format which requires the JPEG plugin.
It wasn't deploying them because it thinks the plugin path is "/Developer/Applications/Qt/plugins"... but since I'm using macports, the actual pluginPath is "/opt/local/share/qt4/plugins".
I took the easy way out and changed the path in my patched version of macdeployqt. I'll send the patch to the macports qt4-mac maintainer.
Did I make things hard for myself by following the Qt documentation for deploying on OSX-- is there some magical XCode or commercial application for creating App bundles that I don't know about that would have saved me days of frustration and work?

