Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. [Solved] Bundle files along with Qt iOS app
Forum Updated to NodeBB v4.3 + New Features

[Solved] Bundle files along with Qt iOS app

Scheduled Pinned Locked Moved Installation and Deployment
10 Posts 5 Posters 9.2k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Mammamia
    wrote on 30 Jul 2013, 11:42 last edited by
    #1

    How can i bundle some files with the Qt iOS app and deploy it on the device. I need to deploy some configuration files and some image files which should be read from the app bundle at Runtime. I can do it by using the Resource file and i cannot do that because i need actual absolute path of the file. Because i am using these image files for the QML files inside my application. (Setting the image to QML will be done after parsing the application XML file which will take only absolute path of the image file). is there any way to bundle external files(images..) with Qt iOS application.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mammamia
      wrote on 1 Aug 2013, 04:01 last edited by
      #2

      Finally i have found the solution for this problem by my own.... :)
      The deployment of files along with the application package in iOS is similar to that of doing in Mac. here is the .pro file,
      @
      TARGET = YourApp
      TEMPLATE = app

      deployment.files = ../YourApp/images
      deployment.path =
      QMAKE_BUNDLE_DATA += deployment
      @

      So the directory "images" with its contents will get automatically copied to the iOS application package (YourApp.app).. If you explore the YourApp.app package you can see the images directory inside it.

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        q8phantom
        wrote on 21 Oct 2013, 08:48 last edited by
        #3

        Hi, I'd testing what you have provided but it isn't working with iOS for me, can you help in this regard please

        as well is there anything spefic for iOS where I can use it in my else statement, something like that I do have in my code

        @unix:!symbian:!maemo5:!win:!android:!macx {
        #Special case for N950 that works, all other devices will use the else case
        DEFINES+=harmattan
        dir1.files = resourc/*
        dir1.path = /opt/$${TARGET}
        INSTALLS += dir1
        } else : android {
        #Special case for android that works, all other devices will use the else case
        dir1.files = resourc/*
        dir1.path = /assets
        INSTALLS += dir1
        } else : macx {
        #Special case for mac that works, all other devices will use the else case
        dir1.files = resourc
        dir1.path = Contents/Resources
        QMAKE_BUNDLE_DATA += dir1
        }
        else {
        dir1.source += resourc/*
        DEPLOYMENTFOLDERS = dir1
        }
        @

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Mammamia
          wrote on 21 Oct 2013, 09:30 last edited by
          #4

          I don't know what you are exactly trying to do. But if u do like what i have mentioned above, then it should work. I have done that only for iOS. Once the packaging is done, if you open your .app file then you can see the directory which u have specified copied inside it... The path which you are specifying for the directory should be relative path that is what i mentioned "../YourApp/images"

          1 Reply Last reply
          0
          • Q Offline
            Q Offline
            q8phantom
            wrote on 21 Oct 2013, 09:46 last edited by
            #5

            Currently, it's not working for me, yes am trying to do as you have suggested

            I'm opening up my project into xCode and doing it there

            1 Reply Last reply
            0
            • C Offline
              C Offline
              clogwog
              wrote on 30 Oct 2013, 00:49 last edited by
              #6

              [quote author="Arun P K" date="1382347850"]I don't know what you are exactly trying to do. But if u do like what i have mentioned above, then it should work. I have done that only for iOS. Once the packaging is done, if you open your .app file then you can see the directory which u have specified copied inside it... The path which you are specifying for the directory should be relative path that is what i mentioned "../YourApp/images"[/quote]

              so in a concrete example if i have :

              @TARGET = YourApp
              TEMPLATE = app

              deployment.files = ../YourApp/qml/YouApp/main.qml
              deployment.path =
              QMAKE_BUNDLE_DATA += deployment@

              would i load the qml like:

              @ QmlApplicationViewer viewer;
              ...
              viewer.setMainQmlFile(QLatin1String("qml/YourApp/main.qml"));@

              or like:

              @ viewer.setMainQmlFile(QLatin1String("../YourApp/qml/YourApp/main.qml"));@

              or

              @ viewer.setMainQmlFile(QLatin1String("qrc:/../YourApp/qml/YourApp/main.qml"));@

              ? is there an example out there that works on ios ?

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hookie
                wrote on 2 Dec 2013, 22:54 last edited by
                #7

                Hiya,
                Did anybody get this working?
                Thanks
                James

                1 Reply Last reply
                0
                • H Offline
                  H Offline
                  hookie
                  wrote on 3 Dec 2013, 07:48 last edited by
                  #8

                  I did find an example of loading a QML file via a resource file

                  @#include <QtCore>
                  #include <QtGui>
                  #include <QtDeclarative>
                  #include <QtWidgets>

                  int main(int argc, char **argv)
                  {
                  QApplication application(argc, argv);

                  QDeclarativeView view;
                  view.setResizeMode(QDeclarativeView::SizeRootObjectToView);
                  view.setSource(QUrl("qrc:qtios/main.qml"));
                  view.show();
                  view.raise();
                  
                  return application.exec&#40;&#41;;
                  

                  }@

                  but if "main.qml" needs to reference other QML files then I become a bit unstuck :-(

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    adrz1
                    wrote on 6 Dec 2013, 15:30 last edited by
                    #9

                    Finally i have found the issue.

                    check qmlapplicationviewer.pri/qtquick1applicationviewer.pri for the iOS deployment configuration

                    @else:ios {
                    copyCommand =
                    for(deploymentfolder, DEPLOYMENTFOLDERS) {
                    source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
                    source = $$replace(source, \\, /)
                    target = $CODESIGNING_FOLDER_PATH/$$eval($${deploymentfolder}.target)
                    target = $$replace(target, \\, /)
                    sourcePathSegments = $$split(source, /)
                    targetFullPath = $$target/$$last(sourcePathSegments)
                    targetFullPath ~= s,/\.?/,/,
                    !isEqual(source,$$targetFullPath) {
                    !isEmpty(copyCommand):copyCommand += &&
                    copyCommand += mkdir -p "$$target"
                    copyCommand += && cp -r "$$source" "$$target"
                    }
                    }
                    !isEmpty(copyCommand) {
                    copyCommand = echo Copying application data... && $$copyCommand
                    !isEmpty(QMAKE_POST_LINK): QMAKE_POST_LINK += ";"
                    QMAKE_POST_LINK += "$$copyCommand"
                    export(QMAKE_POST_LINK)
                    }
                    } @

                    1 Reply Last reply
                    0
                    • A Offline
                      A Offline
                      adrz1
                      wrote on 6 Dec 2013, 15:42 last edited by
                      #10

                      Sorry,

                      do not forget to check qmlapplicationviewer.cpp/qtquick1applicationviewer.cpp

                      @#if defined(Q_OS_IOS)
                      if (!QDir::isAbsolutePath(path))
                      return QString::fromLatin1("%1/%2")
                      .arg(QCoreApplication::applicationDirPath(), path);
                      #elif@

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved