Watched videos, blog post and downloaded their projects and there the core spot lights works accordingly.
I copied code to an empty project and did the same as what they did but still is not working
os: macOS and iOS
on coredataobject I settled up a attribute to index for spotlight and in object it self I putted the attribute name in display name for spotlight.
static let shared = PersistenceController()
var spotlightDelegate: NSCoreDataCoreSpotlightDelegate?
@MainActor
static let preview: PersistenceController = {
let result = PersistenceController(inMemory: true)
let viewContext = result.container.viewContext
for _ in 0..<10 {
let newItem = Item(context: viewContext)
newItem.timestamp = Date()
}
do {
try viewContext.save()
} catch {
let nsError = error as NSError
fatalError("Unresolved error \(nsError), \(nsError.userInfo)")
}
return result
}()
let container: NSPersistentContainer
init(inMemory: Bool = false) {
container = NSPersistentContainer(name: "SpotLightSearchTest")
if inMemory {
container.persistentStoreDescriptions.first!.url = URL(fileURLWithPath: "/dev/null")
}
container.loadPersistentStores(completionHandler: { [weak self] (storeDescription, error) in
if let error = error as NSError? {
fatalError("Unresolved error \(error), \(error.userInfo)")
}
if let description = self?.container.persistentStoreDescriptions.first {
description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
description.type = NSSQLiteStoreType
if let coordinator = self?.container.persistentStoreCoordinator {
self?.spotlightDelegate = NSCoreDataCoreSpotlightDelegate(
forStoreWith: description,
coordinator: coordinator
)
self?.spotlightDelegate?.startSpotlightIndexing()
}
}
})
container.viewContext.automaticallyMergesChangesFromParent = true
}
}
in my @main view
struct SpotLightSearchTestApp: App {
let persistenceController = PersistenceController.shared
var body: some Scene {
WindowGroup {
ContentView()
.environment(\.managedObjectContext, persistenceController.container.viewContext)
.onContinueUserActivity(CSSearchableItemActionType) {_ in
print("")
}
}
}
}
onContinueUserActivity(CSSearchableItemActionType) {_ in
print("")
}
never gets triggered. Sow What am I missing that they dont explain in the blog post or videos ?
Spotlight
RSS for tagSearch for files and index your app’s content for searching using Spotlight.
Posts under Spotlight tag
24 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I wish to have all spotlight services stopped on my MacBook, however with turning all options off in the settings and also the "Help Apple Improve Search" option, however the option turns back on whenever there is a restart on the laptop as well as background services running. How can I disable this permanently?
I have tried to following as well:
sudo mdutil -a -i off
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
sudo launchctl unload -w /System/Library/LaunchAgents/com.apple.metadata.mds.user.plist
sudo rm /Library/Preferences/com.apple.spotlight.plist
sudo launchctl disable system/com.apple.metadata.mds
However with ps aux | grep -E "mds|Spotlight|corespotlightd" it still shows spotlight related services running:
User1 73830 0.0 0.0 410741568 1680 s018 S+ 11:58am 0:00.00 grep -E mds|Spotlight|corespotlightd
root 3170 0.0 0.0 410682288 4816 ?? Ss 20Jan25 4:28.08 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/mds_stores
root 3168 0.0 0.0 427023376 14864 ?? Ss 20Jan25 33:53.97 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Support/mds
User1 593 0.0 0.1 434378432 45456 ?? S 20Jan25 14:00.32 /System/Library/Frameworks/CoreServices.framework/Frameworks/Metadata.framework/Versions/A/Support/corespotlightd
What else can I try in order to stop these and to stay shut off after turning my laptop on and off again?
I used spotlight search for almost everything I do through cmd+space. However ever since i updated my laptop to MacOS Sequoia 15.3.1, the spotlight search won't give me app results:
for example i type "flux" and will get just web-based results, not the app. I tried going into the spotlight settings and only enabling applications to be searched for results and got nothing. I tried the same with the Notes app, i get the same result, i get some notes i wrote as result but not the actual app.
It doesn't happen on all apps for example Brave or Spotify work.
When I search for text in a .html file using the Command-Spacebar spotlight popup the .html file is never shown in the results. On the other hand the .html file does show in the result when I search in the Finder window search field, or when I search in the Terminal using mdfind.
Why is this and how can I fix? I want to use spotlight to find .html files.
You can reproduce the problem like this:
echo spotlighttest > testone.txt
% echo spotlighttest > testtwo.html
% mdfind spotlighttest
2024-12-30 14:22:28.552 mdfind[28326:550500] [UserQueryParser] Loading keywords and predicates for locale "en_US"
2024-12-30 14:22:28.553 mdfind[28326:550500] [UserQueryParser] Loading keywords and predicates for locale "en"
~/Desktop/Spotlighttest/testone.txt
~/Desktop/Spotlighttest/testtwo.html
I believe this shows that both files are index properly, but if you then do Command-Spacebar and search for "Spotlighttest" I think you will see that only testone shows as a result.
Edit I believe this is a change in macOS 15.x and used to work correctly in previous macOS