Qt 5.9.1 macdeployqt: could not find the Qt platform plugin cocoa
I realize this has been asked many times, however I have not seen this specific problem nor have I gained any insight. So here it goes again.
I have a release build that I bundled and then applied macdeployqt on. I can verify that the qt.conf has the line Plugins = PlugIns. I can verify that libqcocoa is installed in PlugIns/platforms in the bundle. I have set the environment variable QT_DEBUG_PLUGIN=1.
When the app runs, according to the debug message, it looks in the <bundle>/Contents/MacOs/platforms directory for libqcocoa and fails.
Any ideas of what to do with this?
Hi, it could be some .dll/dylib that's missing for libqcocoa.dylib to load correctly, for example if the QtPrintSupport framework dll is missing then you'll get that missing plugin cocoa error. You can check which dlls it needs using with otool, e.g.
otool -L libqcocoa.dylib
Seems like everything is there. That doesn't answer the question of why is the QFactoryLoader looking in "<bundle>/Contents/MacOs/platforms" for the lib when the macdeployqt setup puts it in "<bundle>/Contents/PlugIns/platforms".
Sorry, didn't see that, yeah normally it should first look what qt.conf says the plugins are (i.e. "PlugIns").
When it looks in "<bundle>/Contents/MacOs/platforms" that's a Windows vestige, or a fallback when the path specified in qt.conf is missing or invalid.
Actually there are more ways to load that libqcocoa.dylib, if qt.conf fails you, if you excel at hex editing you could change the path specified in "<bundle>/Contents/Frameworks/QtCore.framework/Versions/5/QtCore", to see the current setting, cd there and type:
strings QtCore | grep qt_prfxpath
P.S. I've written a blog post about this but it's a bit old, it says grep for "qt_plugpath" but nowadays it is "qt_prfxpath"
From your docs, I used QCoreApplication::addLibraryPath("PlugIns").
That worked. Now onto the next error:
QtQuick is not installed.
It seems like the deploy tool, while it copied everything, is not doing much else.
Which was just making sure the qml was scanned with macdeployqt's -qmldir flag.