[solved] Qt 5.2.0 on iOS (QMAKE_BUNDLE_DATA and myApp.app/../Documents not working?)
-
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.htmlThat 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 -
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 !
-
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.