iOS5 Storage Support

I’m working on a magazine-like app, and I’m planning to cache downloaded content into system.DocumentsDirectory. I learned recently that this approach is not recommended and might get your app rejected:

http://iphoneincubator.com/blog/data-management/local-file-storage-in-ios-5

A simple workaround that will work immediately is to support storing to
<application_home>/Library/Caches

That is not really a workaround, as this scenario can still happen:
http://www.marco.org/2011/10/13/ios5-caches-cleaning

However, having access to <application_home>/Library/Caches instead of storing files in system.DocumentsDirectory (and getting my app rejected by Apple) is preferable. I’m also guessing this is very easy to do, compared to the real solution.

The real solution is to fully support storing files to iOS Cloud, but I understand that will take a lot more work, and it’s not even currently on the roadmap. [import]uid: 7026 topic_id: 17114 reply_id: 317114[/import] </application_home></application_home>

+1 for /Library/Caches support.

Apple is now rejecting apps that download content and store them in /Documents. [import]uid: 62323 topic_id: 17114 reply_id: 64713[/import]

Will the existing temporary directory support be sufficient? It seems treated the same as Library/Caches.
[import]uid: 7563 topic_id: 17114 reply_id: 64717[/import]

Right now we have:
system.ResourceDirectory -> [AppRoot]
system.DocumentsDirectory -> [AppRoot]/Documents
system.TemporaryDirectory -> [AppRoot]/tmp

In addition to the above, we need something like:

system.CacheDirectory -> /Library/Cache

Apple’s iOS Storage Guideline mentions tmp and Cache separately. tmp for temporary content, Cache for downloaded or generated content.

There is no clear distinction on how iOS manages them though. I’m guessing in a low storage space situation, tmp gets emptied first before Cache. [import]uid: 7026 topic_id: 17114 reply_id: 64943[/import]

Hi there,

I am in desperate need in support for the /library/caches-directory, as a customers App was rejected because of this new information.

Please help!

Thanks
Jörg

Sorry for cross-posting here: http://developer.anscamobile.com/forum/2011/11/17/writeing-librarycaches [import]uid: 10612 topic_id: 17114 reply_id: 68127[/import]

jamirokwai: To fix your problem quickly, would you try system.TemporaryDirectory and resubmit and let us know how it goes?

[import]uid: 7563 topic_id: 17114 reply_id: 68134[/import]

Hi ewing,

I can’t try this, because my customer is eager to going online.
If Apple rejected the App a second time, I fear getting harmed :open_mouth:

Jörg
[import]uid: 10612 topic_id: 17114 reply_id: 68136[/import]

Hi ewing,

is it possible to add the /library/caches to the system-api?
e.g. system.LibraryCachesDirectory?

This would help very much…

I fear, every Corona user will run into this pit, if he offers downloadable content.

Jörg [import]uid: 10612 topic_id: 17114 reply_id: 68232[/import]

Look for notes about this in the next daily build.
[import]uid: 7563 topic_id: 17114 reply_id: 68336[/import]

Hey ewing,

thanks a bunch. One of the reasons to subscribe to Corona is the fast help :slight_smile:

Best
Jörg
[import]uid: 10612 topic_id: 17114 reply_id: 68414[/import]

My first app was submitted yesterday and bounced today because of this - I’ll be watching the build notes. It also says we should use the “Do not backup” attribute. How would I do this or if it’s not supported, can it be put on the really quick list ?

Here’s the tech Q&A they sent me about the attribute and the cache:

******************
Technical Q&A QA1719
How do I prevent files from being backed up to iCloud and iTunes?

Q: My app has a number of files that need to be stored on the device permanently for my app to function properly offline. However, those files do not contain user data and don’t need to be backed up. How should I store those files in iOS 5?

A: Starting in iOS 5.0.1 a new “do not back up” file attribute has been introduced allowing developers to clearly specify which files should be backed up, which files are local caches only and subject to purge, and which files should not be backed up but should also not be purged. In addition, setting this attribute on a folder will prevent the folder and all of its contents from being backed up.

Important: The new “do not back up” attribute will only be used by iOS 5.0.1 or later. On iOS 5.0 and earlier, applications will need to store their data in <application_home>/Library/Caches to avoid having it backed up. Since this attribute is ignored on older systems, you will need to insure your app complies with the iOS Data Storage Guidelines on all versions of iOS that your application supports.
[import]uid: 101604 topic_id: 17114 reply_id: 74829[/import] </application_home>

@leonZak: same problem here. Did you find a solution?

@ansca: could you please add the possibility to set the “Do not backup” attribute - either to files or the system.DocumentsDirectory folder! [import]uid: 13632 topic_id: 17114 reply_id: 78024[/import]

We introduced system.CachesDirectory last month.
[import]uid: 7563 topic_id: 17114 reply_id: 78131[/import]

Thanks ewing - but I can’t find any documentation on system.CachesDirectory anywhere.
What is the difference between system.temporaryDirectory and system.CachesDirectory?
As far as I know the cachesDirectory content will also be deleted on low storage… [import]uid: 13632 topic_id: 17114 reply_id: 78173[/import]

Yeah, documentation is still forth-coming. It goes to a different directory than temporaryDirectory. On iOS/Mac, it should be in the official location Apple wants. Android was just modified so both won’t go to the same directory to avoid file collisions. They now go to their own subdirectory under the app’s temporary directory.

Apple’s documentation now says to put downloaded files that can be redownloaded into the Caches directory. Apple does not say when if/when it will be deleted, but the assumption is when there is low storage.

[import]uid: 7563 topic_id: 17114 reply_id: 78180[/import]

Thanks and sorry I should have read apples docs closer before asking:
http://developer.apple.com/icloud/documentation/data-storage/
It says it all…

So I guess the cachesDirectory will do. It would be nice to have the posibility to set the “do not backup” attribute also though.
[import]uid: 13632 topic_id: 17114 reply_id: 78200[/import]