There appears to be some undocumented changes to the NSCoreDataCoreSpotlightDelegate
in iOS 14. I've been unable to find these changes documented in the NSCoreDataCoreSpotlightDelegate documentation or anywhere else online.
There's quite a bit of debug logging around NSCoreDataCoreSpotlightDelegate
now, including initialization and indexing requets.
NSCoreDataCoreSpotlightDelegate requires NSPersistentHistoryTrackingKey to be enabled in NSPersistentStoreDescription options. (NSInternalInconsistencyException)
The fix is fairly easy - set the NSPersistentHistoryTrackingKey
on your NSPersistentStoreDescription
persistentContainer.persistentStoreDescriptions.forEach {
$0.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
}
'init()' is unavailable
Fairly straightforward fix - init()
used to be available but no longer is. Use the new init(forStoreWith:model:)
instead.
let indexDelegate: NSCoreDataCoreSpotlightDelegate = {
let description = persistentContainer.persistentStoreDescriptions.first!
return NSCoreDataCoreSpotlightDelegate(forStoreWith: description,
model: persistentContainer.managedObjectModel)
}()
NSCoreDataCoreSpotlightDelegate requires the store type to be NSSQLiteStoreType.
Also a fairly straightforward fix, assuming your stack supports the change. NSCoreDataCoreSpotlightDelegate
no longer supports a NSPersistentStoreDescription
with the NSInMemoryStoreType
or NSBinaryStoreType
types - it must be NSSQLiteStoreType
.
let description = NSPersistentStoreDescription()
description.type = NSInMemoryStoreType
description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
persistentContainer.persistentStoreDescriptions = [description]
let spotlightDelegate = NSCoreDataCoreSpotlightDelegate(forStoreWith: description,
model: persistentContainer.managedObjectModel)
CoreData: debug: Dropping "duplicate" indexing request (2).
CoreData: debug: Need additional indexing operation (11)
CoreData: debug: Do *not* need additional indexing operation (0).
WIP - I've yet to figure out these logs. If anyone has any leads, leave a comment.