Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [solved] Qt 5.2.0 on iOS (QMAKE_BUNDLE_DATA and myApp.app/../Documents not working?)

[solved] Qt 5.2.0 on iOS (QMAKE_BUNDLE_DATA and myApp.app/../Documents not working?)

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 2 Posters 3.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.
  • J Offline
    J Offline
    jraichouni
    wrote on last edited by
    #1

    Hi all!

    On an iOS device
    @QStandardPaths::standardLocations(QStandardPaths::DataLocation).first()@

    results into
    @
    myApp.app/../Documents
    @

    That's where persistant app data (e.g. databases) shall be stored as one can read here:
    "iOS Developer Library":https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html

    That is why I tried the following in the .pro file:
    @
    databases.files = ../../src/data/db.sqlite
    ios: databases.path = ../Documents
    QMAKE_BUNDLE_DATA += databases
    @

    This does not work. The database does not get deployed (copied to the device).

    If I change

    @
    ../Documents
    @

    to

    @
    Documents
    @

    it performs, but the data gets placed under
    @
    myApp.app/Documents
    @

    and that is not how it is supposed to be done (see link above).

    Any suggestions?

    Cheers
    jraichouni

    1 Reply Last reply
    0
    • GianlucaG Offline
      GianlucaG Offline
      Gianluca
      wrote on last edited by
      #2

      Everything works fine … you misunderstood the meaning of QMAKE_BUNDLE_DATA.

      On Mac OS and iOS, the applications are not simply executables but they are packaged into a "bundle".
      So, your myApp.app is actually a directory called "bundle" where inside there is the .exe of the application plus something else on which the app depends on.

      Everything can be ONLY DEPLOYED inside a bundle !!

      So, QMAKE_BUNDLE_DATA can only work if you put the stuff INSIDE the myApp.app directory !!

      Instead, the directory myApp.app/../Documents returned also by QStandardPaths::standardLocations(QStandardPaths::DataLocation).first() is another thing.

      On iOS the applications are sandboxed into a directory where there are allowed to write and read files and resources and they are not allowed to access outside this dir.
      Inside this directory (where the app are sandboxed), there is the "Documents" dir where write persistent data, and there is also the app bundle where you can only read files stored there if you need.

      So, in conclusion, you CANNOT DEPLOY a file directly to the "Documents" directory, INSTEAD YOU HAVE TO:

      • save an initial database file inside the app bundle using QMAKE_BUNDLE_DATA
      • when your application start, check if exists a database file into "Documents", if not, copy the initial database from the app bundle to the "Documents" dir.

      There is no alternatives !

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jraichouni
        wrote on last edited by
        #3

        Thanks for the reply!

        Thought about that solution to initialize a move of the data
        from the bundle to the sandbox if necessary.
        Understand that the persistent data is not represented
        below the bundle. I expect an uninstall of an iOS app
        keeping all in myApp.app/../* except the .app bundle itself.

        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