Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved Qt User Plugins & iOS

    Mobile and Embedded
    2
    3
    1566
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • dheerendra
      dheerendra Qt Champions 2022 last edited by dheerendra

      Hi All

      I have developed Custom Qt Plugins(libDataStore.so) and used QPluginLoader to load the plugin in Android. It works fine..

      How to use the same plugin in iOS ?. I know iOS talks about static plugin etc. When I build the same plugin using iOS kit, it build libDataStore.a. This is static lib.

      How do i use this in iOS ? How to bundle this ? Does QPluginLoader works for this ? See the following sample code

      QPluginLoader loader;
          loader.setFileName("libDataStore.a");
          if(loader.load()){
              qDebug() << Q_FUNC_INFO << " Plugin load successfull" << endl;
              QObject *obj = loader.instance();
              if (obj==NULL){
                  qCritical() << "Plugin load failed. Please check "<<endl;return;
              }
              IDataStore *collector = qobject_cast<IDataStore*>(obj);
              connect(this,SIGNAL(storeDB()),obj,SLOT(start()));
          }else {
              qCritical() <<"Plugin load failed. Please check ="<< endl;return;
          }
      
      
      Any inputs on this.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        It's explained here.

        Just in case and IIRC, since Qt 5.9, you should also be able to build Qt dynamically on iOS but it's not yet currently fully automated for the bundling part so you might want to stay with the default current static build.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 2
        • dheerendra
          dheerendra Qt Champions 2022 last edited by dheerendra

          Thank @SGaist . Here is the complete info if somebody requires.

          Plugin Side -

          1. First build your Qt plugin as static lib. For this place the following configuration in your plugin pro file.
            CONFIG +=plugin static
          2. My Plugin name is libDataStore.a & class name of the plugin is DataStore & Interface name is IDataStore
          3. Inside the constructor of DataStore, set the object name
            e.g this.setObjectName("DataCollectorPlugin")
          4. libDataStore.a is present in the directory called /Users/dheeru/Qt/bins

          App Side -

          1. Place the configuration in application pro file like this
            LIBS += -L/Users/dheeru/Qt/bins -lDataStore
          2. Q_IMPORT_PLUGIN(DataStore) in main.cpp. Argument for the macro should match the classname
          3. Use QPluginLoader::staticInstances function. This will return the QObjects list. Since there may be many plugins, objectName is useful here.
          4. After this type cast the required object to Appropriate interface.
          QObjectList objList = QPluginLoader::staticInstances();
              foreach(QObject *obj1, objList){
                  qDebug() <<" IOS Load successful =" << obj1->objectName() << endl;
                  IDataStore *collector = qobject_cast<IDataStore*>(obj1);
                  if(collector!=NULL){
                      connect(this,SIGNAL(storeDB()),obj1,SLOT(start()));
                  }
              }
          

          Once you have object with you, rest of the process is same.

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply Reply Quote 2
          • First post
            Last post