NSPersistentStoreUbiquitousContentNameKey deprecated in iOS 10

I have an app that uses Core Data + iCloud to share data on multiple devices (say, a user with an iPhone and iPad using the same application).


My code does this by using NSPersistentStoreUbiquitousContentNameKey option, and does the necessary magic that was prescribed.


On iOS 10, I'm getting a message, which I'll summarize below (removing specifics mentioning my app name, etc.):


File presenter <PFUbiquityContainerIdentifier: XXXX>: <PFUbiquityLocation: XXXX>: [LONG PATH NAME].cid was still registered at the time this application was suspended, and implements one or more NSFilePresenter messages requiring a response. For NSFilePresenters for file system locations that are accessible to other processes (e.g. iCloud or group containers), you should either call removeFilePresenter: when the process is backgrounded, or remove any implementations of NSFilePresenter methods requiring a response. Otherwise, the system will kill your process instead of risking deadlock.


Since the only iCloud usage I'm doing is Core Data + iCloud, I decided to check the iOS 10 release notes (this seems to be a new message), and nothing was mentioned... except that all the NSPersistentStoreUbituitousContentXXX symbols are now deprecated. I checked the documentation, and indeed they are shown as documented, but no workaround is suggested.


I also checked the WWDC 2016 videos applicable to iCloud and Core Data, and nary a whisper was made regarding this deprecation.


So, I need to know the following...


Is Core Data + iCloud still supported?


If so...


What is the new, non-deprecated way for Core Data + iCloud?


How do I figure out the NSFilePresenter object being used so I can remove it in the proper place, and add it when the app enters foreground again? Or is Core Data supposed to do this automatically (just like UIDocument) and somebody forgot to implement this internally?


If not...


Is this a new example of Apple no longer supporting features it has touted in previous releases?


I hope an Apple Engineer is monitorying this. Right now, I'm trying to debug an issue, and as a start, want to remove these warning messages so that I can assume the bug is somewhere else in my code.

Replies

Thanks for raising the Igensch. I'm getting the same message - if anyone has any insight it would be most appreciated :-)


Ben

P.s. there is some more info in this thread: https://forums.developer.apple.com/thread/48869

I am getting the same error message, did you ever figure out how to work around it?

I was seeing this too a lot, mostly when entering the background. What resolved it for me was using setting up a background task to setup the database. basically:

UIApplication *application = [UIApplication sharedApplication];
  if (self.setupCoreDataTask == UIBackgroundTaskInvalid) {
    __weak typeof(self) weakSelf = self;
    self.setupCoreDataTask = [application beginBackgroundTaskWithName:@"SetupCoreDataTask" expirationHandler:^{
      __strong typeof(weakSelf) strongSelf = weakSelf;
      [application endBackgroundTask:strongSelf.setupCoreDataTask];
      strongSelf.setupCoreDataTask = UIBackgroundTaskInvalid;
    }];
    [self setupCoreData:^{
      self.setupCoreDataTask = UIBackgroundTaskInvalid;
    }];



Hope this helps others.