Post not yet marked as solved
I've recently upgraded to MacOS Sonoma. Spotlight seems to search third-party app names (search for Outlook and you'll find the Outlook app in search results) but it does not seem to surface third-party app content. Is this expected behavior, a widespread bug, or just my issue?
For example, Outlook emails, WhatsApp calls, Evernote notes, Venmo contacts, Booking.com stays, Kayak.com trips...used to all be indexed under their respective apps
I'm considering indexing my app but first wondering if Sonoma even supports it anymore?
Example of App content::
Post not yet marked as solved
I have implemented NSCoreDataCoreSpotlightDelegate, and I missed out the part where the default expirationDate is 1 month, now items that I have added 3 months ago are not showing up in the search index.How do I get NSCoreDataCoreSpotlightDelegate to reindex all the items?I used to be able to call this:mcdcsd.searchableIndex(CSSearchableIndex.default(), reindexAllSearchableItemsWithAcknowledgementHandler: {})And the first time, it will reindex all the items, but if I re-run the app with the above line uncommented again, it will not reindex.If I uninstall the app, install back, then uncomment the above line, then it will index all again for the first time.How do I get it to reindex everything again?
Post not yet marked as solved
Hi all,
has anybody found the trick how to get SwiftData working with SpotLight Search?
Setting the attribute "spotlight" in the Model definition seems to do nothing at all, as pointed out by Paul Hudson in his new book as well
(https://www.hackingwithswift.com/quick-start/swiftdata/how-to-index-swiftdata-objects-in-spotlight)
Thanks a lot!
Content indexed through CSSearchableIndex.default().indexSearchableItems() is no longer searchable from Spotlight.
I created a very small app to demonstrate this. CSSearchableIndex.default().indexSearchableItems() returned no error, yet the result can't be found.
import CoreSpotlight
import SwiftUI
@main
struct testspotlightApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.onContinueUserActivity(CSSearchableItemActionType, perform: handleSpotlight)
}
}
func handleSpotlight(_ userActivity: NSUserActivity) {
print("Found \(userActivity.userInfo?.debugDescription ?? "nothing")")
}
}
import CoreSpotlight
import SwiftUI
struct ContentView: View {
@State var result = ""
var body: some View {
VStack {
Text("Hello!")
Button {
let attribute = CSSearchableItemAttributeSet(contentType: .text)
attribute.title = "a page title"
attribute.contentDescription = "hello this is a page"
attribute.keywords = ["search", "this", "page", "title"]
let item = CSSearchableItem(
uniqueIdentifier: "12345", domainIdentifier: "com.test", attributeSet: attribute)
CSSearchableIndex.default().indexSearchableItems([item]) { error in
if let error {
result = "Failed to index: \(error.localizedDescription)"
} else {
result = "Successefully indexed to spotlight. Try searching 'a page title'"
}
}
} label: {
Text("Index a page").font(.title)
}
Text(result).multilineTextAlignment(.center)
}
.padding()
}
}
Has anyone else seen the same issue?