My application uses iTunes file sharing, which provides the user with the entire contents of the Documents directory, which makes it vulnerable to accidental deletion or manipulation.
I read these documents for hours, but this is a mess, and I hope someone knows from experience. First, in one place they say that I should put these files in the Library directory.
In this technical Q and A, Apple says it persists. In my opinion, this means that I can safely place important user data, such as sqlite3 database files in this directory. When the user is updated to the new version, the contents inside this directory will be saved, it will be saved and will be available after the update:
Applicationscan create their own directories in / Library / and those directories will be backed up and updated.
So / Library / is saved in backups and updates.
For me with poor English, this means: YES, the data will survive. It will not be lost when the user backs up. It will not be lost when updating by the user. I searched for the word "preserved" in several dictionaries, and I'm sure that means "he will survive."
But then there is this note in the iOS Application Programming Guide , which says something completely different! Here they talk about the library directory:
<Application_Home>/Library/ You should not use this directory for user data files. The contents of this directory (with the exception of the Caches subdirectory) are backed up by iTunes. Your application is generally responsible for adding and removing these files. It should also be able to re-create these files as needed because iTunes removes them during a full restoration of the device.
"Should not be used for user data files." (???)
But at the same time, they acknowledge that it is supported by iTunes. OK. So why shouldn't I put user data files there?
/ Library / caches Use this directory to write any application support files that you want to launch the application or during application updates. (...) It should also be able to recreate these files as needed, as iTunes deletes them during a complete restoration of the device.
What?! I have to put these files in Library / Caches. But this directory is not supported by iTunes , as they said above. So this is only saving updates, but not for backup. And the data can be deleted at any time by the system.
Now this is completely confusing for me. From what I understand, I can choose between evil and the devil: the data in / Library / does not withstand updates, but is backed up by iTunes. Data in / Library / Caches is saved in updates, but is not supported by iTunes. They can be deleted by the system (as it is "Cache") at any time.
And, on the other hand, technical Q and A suggest putting this important user data in a user subfolder in / Library /, for example / Library / PrivateDocuments.
Unlike the iOS app programming guide, the technical questions Q and A state: the entire directory / library was always kept during updates and backups
So, indeed, one of the two documents MUST be erroneous. But which one? What is the truth? Please do not speculate! I am looking for answers based on experience, and I feel that there is no way to understand this other than the release of the appendix and prayer. Maybe someone wants to share their experiences, which really worked.