I have a SwiftUI document-based app that for the sake of this discussion stores accounting information: chart of accounts, transactions, etc. Each document is backed by a SwiftData DB.
I'd like to incorporate search into the app so that users can find transactions matching certain criteria, so I went to Core Spotlight. Indexing & search within the app seem to work well.
The issue is that Spotlight APIs appear to be App based & not Document based. I can't find a way to separate Spotlight data by document.
I've tried having each document maintain a UUID as a document-specific identifier and include the identifier in every CSSearchableItem. When performing a query I filter the results with CSUserQueryContext.filterQueries that filter by the document identifier. That works to limit results to the specific file for search operations.
Index updates via CSSearchableIndexDelegate.reindex* methods seem to be App-centric. A user may have file #1 open, but the delegate is being asked to update CSSearchableItems for IDs in other files.
Is there a proper way to use Spotlight for in-app search with a document-based app?
Is there a way to keep Spotlight-indexed data local within the app & not make it available across the system? I.e. I'd like to search within the app only. System-level searches should not surface this data.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I have a SwiftUI application whose primary scene has the simplified definition:
WindowGroup(id: someID, for: SomeModel.self) { $id in
RootView(id: $id)
}
The body of RootView includes:
someView
.navigationTitle($title)
.navigationDocument(model)
The navigation title displays the correct value, however according to the documentation of the above modifiers, the navigation title should be editable and include a proxy icon. Neither of these is the case.
RootView does not include a NavigationStack nor a NavigationSplitView.
The Transferable implementation of the model is correct since drag & drop work fine. The UTType for the model conforms to public.content but not public.data since the model does not represent a file.
Have I overlooked something in the implementation or is this a bug in the current beta?
Xcode: Version 14.0 beta 6 (14A5294g), Feedback: FB11402796.