Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Large files downloaded to Documents and backed up to iCloud

Tags:

ios

I have an iOS app in the app store that can download relatively large files that need to stay on the device for offline use. Those files are currently stored in the app's Documents folder but I'm just now reading that the Documents folder is backed up and should really only be used for user-generated content. This Apple technical Q&A states that the NSURLIsExcludedFromBackupKey should be set to prevent backup. This states that an app's /Library/Caches is the right place to put these kinds of files although further reading suggests that the folder may be cleared when the device is low on storage which is unacceptable for this app. I believe /Library/Application Support/ is then the best location for them -- does this sound right?

Unfortunately, this mistake got through the app review process. What are some best practices for fixing this now that people are using the app and already have some files persisted to the Documents folder and to their backups? It seems I need to move all the existing files and set their NSURLIsExcludedFromBackupKey on app update. How do I guarantee that this is done exactly once and that it isn't interrupted? Is moving the files out of the Documents folder important or could I leave them there? Will changing the files' backup status remove them from existing backups?

I'm using Swift 2.1.1 and targeting iOS 8.0+.

like image 957
Hélène Martin Avatar asked Mar 29 '16 19:03

Hélène Martin


1 Answers

As stated in the technical Q&A, you best bet could be create a subdirectory in the Documents, and exclude that subdirectory once.

like image 82
Allen Avatar answered Oct 05 '22 05:10

Allen