Nominate our 2022 Qt Champions!

[solved] Qt 5.2.0 on iOS (QMAKE_BUNDLE_DATA and not working?)

  • Hi all!

    On an iOS device

    results into

    That's where persistant app data (e.g. databases) shall be stored as one can read here:
    "iOS Developer Library":

    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




    it performs, but the data gets placed under

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

    Any suggestions?


  • 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 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 directory !!

    Instead, the directory 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 !

  • 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* except the .app bundle itself.

Log in to reply