Build Qt qml plugin for iOS (static plugin)
Plugin Pro file like flow:
TEMPLATE = lib
TARGET = iostestqmlplugin
QT += qml quick
CONFIG += qt plugin c++11 static
uri = IosQmlPluginTest # module name
QMAKE_MOC_OPTIONS += -Muri=$$uri # static plugin must use this
2.qmldir file
module IosQmlPluginTest
plugin iostestqmlplugin
typeinfo plugins.qmltypes #static plugin required
classname IosqmlpluginPlugin # static plugin must set classname for plugin c++ class
TimeLabel 1.0 qrc:/TimeLabel.qml # your self qml document
3.qrc file must contains qmldir file, Qt default put qmldir in qrc file with prefix likes: “/qt-project.org/imports/your-plugin-modele-name”, You can special yourself prefix but must endwiths “your-plugin-module-name” and in main cpp need add addImportPath(eg: engine.addImportPath(“qrc:/your-self-prefix-not-contains-your-plugin-module-name”))
4.put plugins.qmltypes, qmldir and plugin library files together into where Qt install dir’s sub fold name qml($$[QT_INSTALL_QML] Qt default serach path), maybe you can special yourself path in your app pro file by variable QMLPATHS(QMLPATHS += /your/plugin/path)
Init the plugin resources(contains qmldir) at plugin c++ class construction function like:Q_INIT_RESOURCE(your-qrc-file-name);
6.pulugins.qmltypes file it’s required. can gernerate by qmlplugindup tool.
7.refrence QtWebView plugin project from Qt source
usually error:
1.static plugin for module “QtQuick” with name “your-module-name” has no metadata URI
fix by add in pro file:QMAKE_MOC_OPTIONS += -Muri=$$URI #URI = your-module-name
thanks from:https://github.com/wang-bin/QtAV/issues/368
2.Plugin “your-module-name” is missing a classname entry
fix by add in qmldir file: classname your-plugin—c++-name
Reference http://doc.qt.io/qt-5.6/qtqml-modules-qmldir.html
module “your-plugin-module-name” is not installed
fix by: Qmldir file must in plugin qrc file, plugins.qmltypes need in the plugin dir and special in qmldir