Search code examples
swiftbackupitunesxcode-6.2

Does iTunes backup core data?


I did some research about backup files and data in iCloud and I was wondering if the Core Data would get saved in an iTunes backup if i would not use any iCloud functionality.

So i got an application with recent server connections saved in core data to fill it back into a UITableView. If i make a device backup with iTunes and restore it later on another device would the recent connections still show up?

None of the Q/A I found did explicit answer this question.

Another question besides: Is it possible to try these itunes-backup things with an app which is in developement?


Solution

  • This depends on where you save your core data database.

    In general the Library and the Documents directory are backed up by iTunes (and by iCloud), tmp and Caches are not backed up.

    See: Apple Documentation - iOS Standard Directories: Where Files Reside

    AppName.app
    This is the app’s bundle. This directory contains the app and all of its resources. You cannot write to this directory. To prevent tampering, the bundle directory is signed at installation time. Writing to this directory changes the signature and prevents your app from launching. You can, however, gain read-only access to any resources stored in the apps bundle. For more information, see the Resource Programming Guide
    The contents of this directory are not backed up by iTunes. However, iTunes does perform an initial sync of any apps purchased from the App Store.

    Documents/
    Use this directory to store user-generated content. The contents of this directory can be made available to the user through file sharing; therefore, his directory should only contain files that you may wish to expose to the user.
    The contents of this directory are backed up by iTunes.

    Documents/Inbox
    Use this directory to access files that your app was asked to open by outside entities. Specifically, the Mail program places email attachments associated with your app in this directory. Document interaction controllers may also place files in it. Your app can read and delete files in this directory but cannot create new files or write to existing files. If the user tries to edit a file in this directory, your app must silently move it out of the directory before making any changes.
    The contents of this directory are backed up by iTunes.

    Library/
    This is the top-level directory for any files that are not user data files. You typically put files in one of several standard subdirectories. iOS apps commonly use the Application Support and Caches subdirectories; however, you can create custom subdirectories. Use the Library subdirectories for any files you don’t want exposed to the user. Your app should not use these directories for user data files.
    The contents of the Library directory (with the exception of the Caches subdirectory) are backed up by iTunes.
    For additional information about the Library directory and its commonly used subdirectories, see The Library Directory Stores App-Specific Files.

    tmp/ Use this directory to write temporary files that do not need to persist between launches of your app. Your app should remove files from this directory when they are no longer needed; however, the system may purge this directory when your app is not running.
    The contents of this directory are not backed up by iTunes.