In an app we can use FileManager.SearchPathDirectory.cachesDirectory (objc:NSCachesDirectory) to store files that could be recreated if necessary (and will be automatically deleted by iOS in cases of low disk memory).
For app groups, there is a shared location that is automatically created as soon as we use containerURL(forSecurityApplicationGroupIdentifier:) (objc:containerURLForSecurityApplicationGroupIdentifier) :
Library/Caches
- Is this cache directory (created by iOS) also gets automatically deleted by iOS in cases of low disk memory ?
I also have more related questions :
- does this cache directory size count in the used disk space by the app displayed in the settings app ?
- is this cache directory (and same question for the top containerURL directory) saved in the cloud backups ?
Does anyone have any information about this?
FYI, most of the questions below are answered in "Optimizing Your App’s Data for iCloud Backup", which also includes some additional details and code snippets.
Is this cache directory (created by iOS) also gets automatically deleted by iOS in cases of low disk memory ?
Yes though, to be clear, we delete the contents of "Caches", not the directory itself. This is also true of "tmp", the other directory we purge.
does this cache directory size count in the used disk space by the app displayed in the settings app ?
I don't believe so.
is this cache directory... saved in the cloud backups ?
No. Both "Caches" and "tmp" are excluded from backups by the the system.
(and same question for the top containerURL directory)
Yes. The system should be backing up all of your apps data containers. More specifically, it should be backing up all of your apps data unless:
-It's in "Caches" or "tmp" (see earlier point).
-It's been explicitly excluded from the backup.
-It's already stored in iCloud Drive (and would thus be retrieved from there).
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware