I eventually raised a TSI for this, and Developer Technical Support indicated that I should file a bug with NSMetadataQueryAccessibleUbiquitousExternalDocumentsScope “since it doesn’t behave as documented”. I've filed that as FB9631965.
In the mean-time, I've discovered that NSFilePresenter's documentation describes it as “The interface […] to inform an object […] about changes to that file”, and allows us to monitor imported directories for changes! 🎉
It does, however, have some decade-old bugs that mean the only subitem-related method that actually works consistently is presentedSubitemDidChange(at:). It's a bit of a blunt instrument, but it'll do for my use case.
Post
Replies
Boosts
Views
Activity
@Nick: Initialising against the private database as you suggested works on iOS 14.5. It would be really useful if that was in the documentation for initializeCloudKitSchema() if it's not likely to be fixed to support initialising against a public database, to avoid others falling into the trap I did! I've commented to that effect on FB8995024, too.
On iOS 15, I can't verify if that's also the case yet because of FB9156476 (the feedback I created during our lab session). For the sake of anyone else who finds this thread, the error that feedback refers to is below.
FB9156476 (iOS 15 NSPersistentCloudKitContainer can't sync initial data from server with “Failed to sync user keys”) error:
2021-06-10 21:51:53.672655+0100 MyApp[1230:15921] [error] error: CoreData+CloudKit: -[NSCloudKitMirroringDelegate _performSetupRequest:]_block_invoke(955): <NSCloudKitMirroringDelegate: 0x60000131c180>: Failed to set up CloudKit integration for store: <NSSQLCore: 0x7fa1b1e05f50> (URL: file:///Users/steve/Library/Developer/CoreSimulator/Devices/59435252-2CF1-4980-8ABB-4B46B21385AA/data/Containers/Data/Application/CC6176E7-4FDC-4842-A68F-C6198170CAEA/Library/Application%20Support/private.sqlite)
<CKError 0x600002881c50: "Partial Failure" (2/1011); "Failed to modify some record zones"; partial errors: {
com.apple.coredata.cloudkit.zone:__defaultOwner__ = <CKError 0x600002805470: "Internal Error" (1/5000); "Failed to sync user keys">
}>
This is still reproducible on iOS 15.0b1 simulators (19A5261u) in Xcode 13.0 beta (13A5154h), with the same code. I've attached the console log I'm seeing on those builds to the aforementioned feedback.
I am *so* pleased to see I'm not the only one with this problem: I thought I was losing my mind!
@Quinn: I've filed rdar://FB8811908 (CoreSpotlight thumbnails not shown on devices running iOS 14.0 (Regression from iOS 13.6)). As I say there, this is minimally reproducible (for me, at least). I've also added the main files from a minimal test app to a gist - https://gist.github.com/SteveMarshall/59810e483c74e84c7bcdb5fcfcad94e7.
The steps I took to consistently reproduce (also in the feedback):
Steps to reproduce: Create new Xcode project using the iOS App template (Interface: SwiftUI, Life Cycle: UIKit App Delegate, Language: Swift, disable Core Data and Tests)
Change deployment target to iOS 13.6
In ContentView.swift, update ContentView to the following:
struct ContentView: View {
		var body: some View {
				Text("Hello, UIKit!")
						.onAppear(perform: {
								let attributeSet = CSSearchableItemAttributeSet(
										itemContentType: "public.content"
								)
								attributeSet.displayName = "Hello UIKit?"
								attributeSet.thumbnailData = UIImage(
										systemName: "hand.thumbsup.fill"
								)?.pngData()
								let item = CSSearchableItem(
										uniqueIdentifier: "uikit.shelloworld",
										domainIdentifier: nil,
										attributeSet: attributeSet)
								CSSearchableIndex.default()
										.indexSearchableItems([item]) { (error) in
										print(error as Any)
								}
						})
		}
}
4. Deploy to a physical device running iOS 14.0.1 and search for Hello UIKit, and observe the missing image. Contrast to results for the same search in simulator running iOS 14.0, or on devices running iOS 13.6.