3

I have written a new version (1.0.1) of the iOS application. The background of the application is that it download files from server and stores in Documents. As per Apple guidelines, any file generated by user shouldn't be backed up on cloud, therefore I have marked them as NSURLIsExcludedFromBackupKey. But now when I am updating on the device using Adhoc distribution profile, any user generated file in Documents folders are getting deleted.

Is there any way to avoid the deletion of those files, as these are essential files to have for application to run.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Shahid Azim
  • 805
  • 1
  • 7
  • 10
  • have you put any code to replace the document folder content? – Retro Apr 21 '14 at 15:16
  • No, it is a normal update process and I am assuming if the app will be updated then it should keep those files. Do I need to write any custom code to avoid the deletion during update process, if possible? – Shahid Azim Apr 21 '14 at 15:21
  • If you are copying the files from bundle to document folder then check if file is exist and then do not overwrite it. – Retro Apr 21 '14 at 15:22
  • These files are not a part of bundle, were downloaded from the server. – Shahid Azim Apr 21 '14 at 15:26
  • did you debug the app as its strange that file is getting deleted from document folder as they are not replacing or document folder not getting deleted, check are they in any kinda folder which is overwriting programmatically. – Retro Apr 21 '14 at 15:30
  • Yes the app is downloading files into Documents folder directly, no sub folders, and there isn't any code to overwrite any of the pre-generated file. – Shahid Azim Apr 21 '14 at 15:45
  • Anything new on this issue? We have just hit this very same situation, where the system deletes hundreds of megabytes of data from the `Documents` folder with the `NSURLIsExcludedFromBackupKey` flag. Some of our users where in AirPlane mode when they needed that data so there is no way for them to re-download the data. – shelll Apr 24 '15 at 10:58

1 Answers1

3

You seem to have things backwards. You should backup user-generated files. What you should not backup are files that can easily be replaced by downloading them again or generating them again as needed.

If you mark a file so it is excluded from backup then that means the file can easily be replaced.

When you install the app update, those files aren't copied over to the updated app. On first run, your app should detect that they are missing and automatically replace them if needed.

If these are files that can't be replaced automatically then do not flag them with NSURLIsExcludedFromBackupKey.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • 1
    Thanks for your suggestion, and it make sense. But the problem is that I am storing images in Documents folder by flagging them NSURLIsExcludedFromBackupKey (as per Apple's advise), and it can be 100s of images and can use up to 100s of MB. To re-download those files again after update is not realistic, there must be some way to store somewhere and update app without re-downloading them? – Shahid Azim Apr 21 '14 at 22:44
  • 2
    One more thing to mention, I can't store these files without NSURLIsExcludedFromBackupKey as per Apple's restrictions that you couldn't store application generated files more than 10mb in my documents to avoid massive icloud backup. – Shahid Azim Apr 22 '14 at 06:19
  • I have the exact same issue as suggested in the last comment. Apple prevents you from having large files backed up and will reject your app if such files aren't flagged with NSURLIsExcludedFromBackupKey. So what is the solution? It's not fair to expect the user to have to download all these (big) files again on app update. It will deter the user from ever updating again. Thanks Apple for another frustrating policy. – Ash Feb 12 '16 at 02:16