Puzzled by how to deal with iOS 8.1 "Data container" changes to app sandbox filesystem [Solved]
I have an Qt+QML app built with Qt 5.3.1 running nicely on an iOS 7.1 iPad (and working just as well on Mac and Linux platforms with negligible #ifdef-ed code sections).
However, trying it out on an iOS 8.1 iPad for the first time, it seems to have some trouble finding files it finds no problem on iOS 7.1.
Basically, on iOS 7.1 as I understand it the app starts with its current directory in the app bundle, and the app's sandbox's Documents and Library directories (where the app expects to access and manage some files) are simply found at ../Documents and ../Library. That's worked well for me so far anyway.
I haven't completed a thorough investigation yet, but on iOS 8.1 the app no longer seems to be able to locate these dirs or at least the files within them via those paths. I strongly suspect this is related to something mentioned in the "iOS 8.1 release notes":https://developer.apple.com/Library/ios/releasenotes/Miscellaneous/RN-iOSSDK-8.1/index.html : "The file system layout of app containers has changed on disk. Rather than relying on hard-coded directory structure..." and then the rest is NS* gobbledegook to me but appears to show some API calls an app is expected to make to obtain paths to these directories.
Looking at Apple's File System Programming Guide's "File System Basics":https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html section I am pretty sure the mention of a "Data Container" in the sandbox is something new since I last looked at it (yup in fact checking the wayback machine's version of that page for March 2013 I see the app bundle and Documents, Library etc dirs are just shown side by side in the sandbox; no mention of any "container".)
Can anyone enlighten me if there's some simple Qt way of obtaining a path to an app's Documents and Library folders, or the "Data container"'s root? Worst case it looks like it may need some native Objectionable-C coding to prod these APIs, but maybe there is some Qt API for it already I've missed... for example it seems like the sort of thing there ought to be a QDir static member for (or what does QDir::home() return on iOS, for example?) Alternatively, is there just some URL file:// notation which can access it? Or are there any changes post Qt 5.3.1 which would make ../Documents work transparently again?
Thanks for any tips
Aha just noticed "QStandardPaths":http://qt-project.org/doc/qt-5/qstandardpaths.html which seems like exactly what you'd expect to tell you where to find some Documents & Library directories.
However, while it mentions all of OS X, Windows, Blackberry, Linux and Android... no iOS! Wonder if it does anything sensible/useful there...?
The doc seems incomplete, you can use QStandardPaths on iOS without any problem.
OK confirmed (logging to stderr) that on iOS7:
- QStandardPaths Documents locations: /var/mobile/Applications/<uuid>/Documents
- QStandardPaths Data locations: /var/mobile/Applications/<uuid>/Documents] (surprisingly! More on this below)
- QStandardPaths Cache locations: /var/mobile/Applications/<uuid>/Library/Caches
Haven't checked iOS8 yet because xcode5 is refusing to talk to my iOS8 iPad (says I need an iOS8 SDK, which seems to imply installing xcode6 but I'm a bit "wary":http://stackoverflow.com/questions/25945878/cannot-compile-qt-with-xcode-6-0-1 of going there for now. However xcode5-compiled .ipa files still seem to be installable/runnable on iOS8 just fine so the easiest thing is just to try and use the QStandardPaths in my app and see if it works better than it does currently.
One thing which quite surprised me: the "Data" QStandardPath location is also returning "Documents" and not "Library" or "Library/Application Support" which is what you'd expect from Apple's "documentation":https://developer.apple.com/library/ios/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileSystemOverview/FileSystemOverview.html (see "iOS Standard Directories: Where Files Reside"). I also note that on OSX the QStandardPaths Library location is "~/Library/Application Support/<APPNAME>", "/Library/Application Support/<APPNAME>"... so I'm dubious the iOS result is correct/useful/appropriate (checked on Qt 5.3.2).
I see there's a Jira issue for the missing iOS QStandardPaths docs: "QTBUG-36171":https://bugreports.qt-project.org/browse/QTBUG-36171
There wasn't one for the Data location is Documents/ thing; this seems wrong enough to me to create "QTBUG-42276":https://bugreports.qt-project.org/browse/QTBUG-42276
Indeed, there's some inconstancies here. Thanks for the report
Fixes on the way
Thanks; will mark this a Solved.