Unsolved Qt plugin identifier issue
-
Hi, I've got a Qt plugin which is static for iOS build but dynamic for other systems. This way the
IID
needs to be different.#include <QtQuick> #include <QtGlobal> class myPlugin : public QQmlExtensionPlugin { Q_OBJECT #if defined(Q_OS_IOS) Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0") #else Q_PLUGIN_METADATA(IID "myPlugin") #endif
The problem is that on iOS it doesn't seem to be using the correct
IID
. I would get runtime error that myPlugin cannot be found.- I can confirm
Q_OS_IOS
is defined - when I use#pragma message
to see which branch is being used I get the correct one. - When I comment out the conditions and leave just
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
the app works fine. - When I comment out only
Q_PLUGIN_METADATA(IID "myPlugin")
the code won't compile with
Undefined symbols for architecture arm64: "qt_static_plugin_myPlugin()", referenced from: ...
I'm baffled - it kind of looks like the compiler is using and not using the correct conditional branch at the same time :).
- I can confirm
-
@_eph said in Qt plugin identifier issue:
I'm baffled - it kind of looks like the compiler is using and not using the correct conditional branch at the same time :).
Perhaps the interface is prepared by MOC (Meta Object Compiler) which is known to be quite dumb.
A few solutions:
- check the generated moc_*.h file - does it contain correct information?
- use 2 separate files for your plugin, one for iOS, one for remaining platforms
- have one plugin "template" (same file you have now, but a single replace line for metadata) then use
QMAKE_SUBSTITUTES
to dynamically generate proper plugin file during compilation