-
Daniel Albuschat
-
mschlander
-
yshurik
-
Jon
-
eric
-
yshurik
-
Chen Wang
-
yshurik
-
Chen Wang
-
Mason
-
Oliver Knoll
-
Oliver Knoll
-
Oliver Knoll
-
yshurik
-
yshurik
-
David
-
David
Submiting a Qt App to Mac App Store
Maybe you already thought about creation a Qt application for Mac App Store or submitting an existing one. While I am on vacations I made a probe of such possibility – you may know that Apple and Nokia developing now different ecosystems of languages/libraries and you may expect to have troubles of bypassing Qt application into Mac App Store. Anyway I found that it is not so complicated as expected, though it took time to do all preparations, my application passed and was published in store with first attempt.
For long time I had one application in my attic. It was an interesting experiment for studying and remembering foreign words. This application do kind of training by repeating words and force you to type correct spelling while application pronounce it to you using TTS (surely you need high-quality voice engine – I used voices from Infovox iVox). That was pretty effective and helped me a lot for studying new words and forming active vocabulary for Norwegian. Because of hearing, reading and typing it makes very effective associations in your brains. The application is cross-platform and requires only QtGui, QtXml and QtCore, also qt plugins are not need.
First I worked on adjustments of widgets and look-and-feel to have app closer to Mac style. It wasn’t complicated because on each release Nokia improves drawing of widgets to have it very close to native views. You can find differences in user interface if you know especialities.
Then application (bundle) was build with inclusion of all required libs as private frameworks. I got too much for such small application — about 60MB. For me it is too heavy and I decided to make it smaller. Also after checking Qt forums I found that some patches are required for Qt to get a ticket into store.
It was chosen Carbon version of Qt because I found some glitches in GUI when used Cocoa – so I decided not to spend time on it. Then disabled everything that is not needed in configure, also used 10.5 sdk and only 32 bit:
I got about 30MB for Frameworks. But Framework folders can be downsized — no need for debug versions of libs, no need for header files because frameworks are private. Because I used copying of Frameworks using QMAKE_POST_LINK, it looks like this:
QMAKE_POST_LINK = \ mkdir -p $${BUNDLETARGET}/Contents/Frameworks; \ cp -R $${QTFRAMEWORKSPATH}/QtCore.framework \ $${QTFRAMEWORKSPATH}/QtGui.framework \ $${QTFRAMEWORKSPATH}/QtXml.framework \ $${BUNDLETARGET}/Contents/Frameworks; \ ... \ strip $(TARGET); \ strip -x $${BUNDLETARGET}/Contents/Frameworks/QtCore.framework/Versions/4/QtCore; \ strip -x $${BUNDLETARGET}/Contents/Frameworks/QtGui.framework/Versions/4/QtGui; \ strip -x $${BUNDLETARGET}/Contents/Frameworks/QtXml.framework/Versions/4/QtXml; \ \ rm -rf `find $${BUNDLETARGET} -name "*.prl"`; \ rm -rf `find $${BUNDLETARGET} -name "*.lproj"`; \ rm -rf `find $${BUNDLETARGET} -name "*_debug*"`; \ rm -rf `find $${BUNDLETARGET} -name "Headers"`; \ \ otool -L $(TARGET); \ otool -L $${BUNDLETARGET}/Contents/Frameworks/QtCore.framework/Versions/4/QtCore; \ otool -L $${BUNDLETARGET}/Contents/Frameworks/QtGui.framework/Versions/4/QtGui; \ otool -L $${BUNDLETARGET}/Contents/Frameworks/QtXml.framework/Versions/4/QtXml; \ \ echo "Ok"Result — 12MB, in Mac App Store – just 5.3MB. This is great just for small application which is based on non-native GUI frameworks.
So we resolved size issue, now it is time to get Qt ready to pass examination and be ready for store.
First — app should keep own data in ~/Library/Application Support/com.organization.appname, so we download patch mac-app-store-cache-location.diff. After applying it, when using QDesktopServices::storageLocation() we get right path to location where to keep app/user data.
Second — Qt apps always read and write ~/Library/Preferences/com.nokia.qt.plist. You can not disable it due to need of common settings of Qt Applications. But Apple has restrictions for applications not to write settings of other applications. So we download second patch for Qt — mac-settings-in-app-area.diff, and in main() in very beginning add a call: qt_force_trolltech_settings_to_app_area(true);
Also there are two patches — first one is for removal Hide/Show All from application menu, but I found this patch later, though my app passed control without it, and second one is for SQLite — but I did not study this one (no need for my app).
Frameworks should be adjusted to have them referenced to each other using @executable_path. You can see it easily by otool utility:
Add this to QMAKE_POST_LINK:
install_name_tool -id @executable_path/../Frameworks/QtCore.framework/Versions/4/QtCore \ $${BUNDLETARGET}/Contents/Frameworks/QtCore.framework/Versions/4/QtCore; \ install_name_tool -id @executable_path/../Frameworks/QtGui.framework/Versions/4/QtGui \ $${BUNDLETARGET}/Contents/Frameworks/QtGui.framework/Versions/4/QtGui; \ install_name_tool -id @executable_path/../Frameworks/QtXml.framework/Versions/4/QtXml \ $${BUNDLETARGET}/Contents/Frameworks/QtXml.framework/Versions/4/QtXml; \ ... +and same for other referencesNow everything is fine:
Now just by copying .app bundle onto another Mac without developer tools and Qt your App should start without problems.
Also you need to sign your app by your signature(certificate) as Mac developer. You have to get such certificate from developer.apple.com, pay $99 for year subscription if you haven’t done it yet.
/usr/bin/codesign -f -s 3rd\ Party\ Mac\ Developer\ Application:\ Firstname\ Lastname $${BUNDLETARGET}; \and add this to “pro” file too.
But for submitting the application into App Store, I had to start Xcode, build it in dsym+dwarf mode, make it signed, added prepared Frameworks by «New Build Phase -> New Copy Files Build Phase». Everything was tested with otool to see all dependencies, checked on another Mac and got ready to send into App Store (If you know how to do all such stuff by scripts please let me know – prefer to do everything in Qt Creator).
Summary —
1. It is not so complicated as for first sight.
2. Apple is okay to accept Qt apps, just need to apply some patches to Qt.
3. Size of Qt App (bundle) is small enough (maybe if you include several resources into app bundle then size of Qt frameworks may become a minor part).
Result — http://itunes.apple.com/us/app/togmeg/id445287955
References:
Main source of information — http://bugreports.qt.nokia.com/browse/QTBUG-16549