QML plugin on iOS



  • I've made a QML plugin and have it working on android but once trying to get it running in the iOS simulator, it says the plugin can't be found. It is linked in and found by the IDE and I can recreate the message with any other custom QML plugin like the TimeExample one. Has anyone used a QML plugin on iOS, and if so how?



  • Quite curious about this one... any progress?

    I have an application using a plugin (built from my own code) on Linux and OSX (just for the nice clean separation between components it forces on you) and want to port it to iOS (little project for next week) maintaining the plugin architecture (rather than just folding all the code into one executable and registering the item classes directly with the hosting QQuickView) ... can plugins be got to work on iOS? Are there pitfalls? (iOS 8+ as min spec for - apparently - some new dylib support not an issue for me).



  • After playing with plugins a bit I have them working nicely on Linux and OSX (no Android or Windows here yet). iOS remains problematic though.

    Some comments here at https://forum.qt.io/topic/37840/static-linking-of-custom-qtquick-plugins and https://forum.qt.io/topic/49254/solved-problem-with-ios-app-and-qml-plugin suggest people have had some success using static plugins on iOS (with some obscure QMAKE_MOC_OPTIONS += -Muri=... needed). I've yet to manage to get it to work for me though :^(

    I was a bit hopeful iOS 8+'s supposed newfound love for dylibs would allow the same dynamic plugin setup as the other platforms use to work easily. I also note the QPluginLoader's docs refers to .dylib use on OSX and iOS. But it seems the iOS build of a plugin target just builds a static lib*.a anyway (whether you specify static or not).

    Investigations continue...

    Tim



  • Finally got a QQmlExtensionPlugin-based QML plugin working on iOS (with static linking for the native code).

    Code is at https://bitbucket.org/timday/qt-example-plugin/overview for the benefit of anyone else in the same boat (will add a link from the iOS wiki at some point). It draws on some details from the links in the previous post in this thread, but the one final thing it needed was an explicit

    qobject_cast<QQmlExtensionPlugin*>(qt_static_plugin_ExamplePlugin().instance())->registerTypes("ExamplePlugin");
    

    in the application, which I borrowed from https://bugreports.qt.io/browse/QTBUG-28357 (closed) which described some similar issues to what I was seeing for my plugin, but for Qt's own QML plugins used statically in the 5.0/5.1 era.

    Not sure what's going on; I'm including Q_IMPORT_PLUGIN(ExamplePlugin), but nothing calls the registerTypes unless I do explicitly with the additional code above. On Linux and OSX (my other platforms of interest) the project does dynamic libs which work fine. I suppose I should try static there too to see if this is an iOS specific issue, or if it affects those platforms too (in which case it's more likely I'm misunderstanding something about static QML plugins). If it's just iOS I may open a bug, but be interested to hear of any obvious broken-ness in what I'm doing in the example code linked above.



  • Tried out static plugins on OSX and Linux (in a branch of the example code repo linked in previous post in thread)... and ran into the same need for explicit call to registerTypes for the plugins to be importable by QML. So raised https://bugreports.qt.io/browse/QTBUG-47827 in the Jira.

    Oh, and one thing it's worth mentioning about the original post's mention of use of an iOS simulator... with xcode it's easy to get into a situation where your plugin is built for arm architecture, but then when you build for the simulator that actually builds native to the Mac HW x86 binaries... which then can't link (or was it load) the arm plugins. I didn't try and get any further with the simulator, just used an actual arm iDevice.



  • Hello dear,
    For a successful example, see QtAV project on GitHub.
    Please note that copying files into Qt installation folder is tricky but project structure and way of implementation and deployment is right.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.