App data is not restored when device is restored via iCloud Backup

Users have reported that, when they restore a device from an iCloud Backup (as opposed to an iTunes Backup), the data for my app is not restored. It is not clear to me the steps I need to take to ensure that my app data is restored when the entire device is restored from an iCloud backup. I do not have iCloud enabled in app capabilities; is this one of the steps I need to take to make sure my data is included in the restore? What are the other steps I need to take and things I need to check? Does this have something to do with where my data is stored on the device?

Replies

Hi appdev,


You shouldn't need iCloud enabled in App Capabilities for iCloud backups to happen. However you probably do need to consider where the app data is stored:


  • Everything in your app’s home directory is backed up to iCloud, with the exception of the application bundle itself, the caches directory, and temp directory.
  • Only documents and other data that is user-generated, or that cannot otherwise be recreated by your application, should be stored in the <Application_Home>/Documents directory and will be automatically backed up by iCloud.
  • Data that can be downloaded again or regenerated should be stored in the <Application_Home>/Library/Cachesdirectory. Examples of files you should put in the Caches directory include database cache files and downloadable content, such as that used by magazine, newspaper, and map applications.
  • Data that is used only temporarily should be stored in the <Application_Home>/tmp directory. Although these files are not backed up to iCloud, remember to delete those files when you are done with them so that they do not continue to consume space on the user’s device.


The above is taken from https://developer.apple.com/icloud/documentation/data-storage/index.html


Max.