7

Is there a way to prevent your application data (Documents folder contents) from being synced to iCloud? (other then storing it in Caches directory because of the new issues in iOS5 with doing that) My Application has need of storing data on the device, but for security reasons it can't be synchronized to any 3rd party (including Apple).

Charles
  • 50,943
  • 13
  • 104
  • 142
BadPirate
  • 25,802
  • 10
  • 92
  • 123

2 Answers2

8

From: https://developer.apple.com/library/ios/#qa/qa1719/_index.html

You can use the following method to set the "do not back up" extended attribute. Whenever you create a file or folder that should not be backed up, write the data to the file and then call this method, passing in a URL to the file.

#include <sys/xattr.h>
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
    const char* filePath = [[URL path] fileSystemRepresentation];

    const char* attrName = "com.apple.MobileBackup";
    u_int8_t attrValue = 1;

    int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
    return result == 0;
}

More information can be found: https://developer.apple.com/icloud/documentation/data-storage/

BadPirate
  • 25,802
  • 10
  • 92
  • 123
  • "iOS 5.0.1 beta and iTunes 10.5.1 beta are pre-release software and are considered Apple Confidential Information and are subject to the terms of your iOS Developer Program License Agreement. Unauthorized distribution or disclosure of Apple Confidential Information is prohibited." – zekel Nov 03 '11 at 19:00
  • 2
    I didn't realize I would get flagged down by the Apple Police. I hope CNN doesn't get a hold of this hot confidential fix. They've been speculating about this feature in the media for months! It will spoil Apple's big unveiling. Tim will be sad. – BadPirate Nov 03 '11 at 19:33
  • Just letting you know you were breaking your NDA in case you weren't deliberately ignoring it. My bad. – zekel Nov 03 '11 at 21:20
  • Just be aware that if you set the "do no back up" attribute, it also won't be backed up to the user's local iTunes when the synch. So if, for instance, the user does a restore of their iOS and then restores their device from a backup, all data for your app will have been lost. Users would need to know in advance that this was going to be the case or they might be quite ticked off. – Duncan Babbage Nov 12 '11 at 00:07
  • Yeah, it's a struggle we have to deal with in our product, (security product) as the customer has a requirement to be able to remote wipe all copies of backed up (and even encrypted) data, and backing up to iTunes / iCloud lets the data out into "the wild". Good point for others using the feature however. My guess is you have some reason to not backup the data (whether it be itunes or icloud) if you choose to use the attribute. – BadPirate Nov 14 '11 at 19:26
0

See iOS App Programming Guide: iCloud Storage.

It describes that an app must be signed with iCloud entitlements so that seems to imply that if you don't do anything then you should be fine.

Dan J
  • 16,319
  • 7
  • 50
  • 82
onnoweb
  • 3,038
  • 22
  • 29