Spotlight

RSS for tag

Search for files and index your app’s content for searching using Spotlight.

Posts under Spotlight tag

30 Posts

Post

Replies

Boosts

Views

Activity

AppIntents + CSSearchableItemAttributeSet: only displayName indexed?
On iOS 18, I'm trying to index documents in Spotlight using the new combination of AppIntents+IndexedEntity. However, I don't seem to be able to index the textContent of the document. Only the displayName seems to be indexed. As recommended, I start with the defaultAttributeSet: /// I call this function to index in Spotlight static func indexInSpotlight(document: Document) async { do { if let entity = document.toEntity { try await CSSearchableIndex.default().indexAppEntities([entity]) } } catch { DLog("Spotlight: could not index document: \(document.name ?? "")") } } /// This is the corresponding IndexedEntity with the attributeSet @available(iOS 18, *) extension DocumentEntity { var attributeSet: CSSearchableItemAttributeSet { let attributeSet = defaultAttributeSet attributeSet.title = title attributeSet.displayName = title attributeSet.textContent = docContent attributeSet.thumbnailData = thumbnailData attributeSet.kind = "document" attributeSet.creator = Constants.APP_NAME return attributeSet } } How can I have more that the displayName to be indexed? Thanks :-)
7
0
318
2d
The Spotlight Import Extension does not allow to inspect document bundles to get the metadata for the spotlight
I've made working Spotlight Import Extension with in macOS 15.5 (24F74). mdimport confirm it's installed, and working. The problem is related to accessing data inside document bundles (package directory) class ImportExtension: CSImportExtension { override func update(_ attributes: CSSearchableItemAttributeSet, forFileAt url: URL) throws { // ERROR: The file "QuickSort.notepad" couldn't be opened because you don't have permission to view it. let fileWrapper = try FileWrapper(url: url) } } forFileAt url points to a bundle. In order to read the metadata the extension needs to load the bundle from url and access its content, however in the sandbox environment,t the url allows only access to the bundle directory itself in particular NSFileWrapper(url: url) fails with error "The file "name.extension" couldn't be opened because you don't have permission to view it.", and effectively prevent from providing useful metadata. Is there a way to access the Document Bundle content in order to read the metadata for Spotlight?
2
0
127
1w
Spotlight App Extension does not persist custom Attributes
We are in the process of updating our legacy Spotlight MDImporter to the new macOS Spotlight App Extension. The transition works well for standard attributes such as title, textContent, and keywords. However, we encounter an issue when adding custom attributes to the CSSearchableItemAttributeSet. These custom attributes are not being persisted, which means they cannot be queried using a Spotlight NSMetadataQuery. Has anyone an idea on how to append custom attributes so that they are included in the indexed file status, as displayed by the shell command mdimport -t -d3 <path> A sample project illustrating the problem is available here: https://www.dropbox.com/scl/fi/t8qg51cr1rpwouxdl900b/2024-09-04-Spotlight-extAttr.zip?rlkey=lg6n9060snw7mrz6jsxfdlnfa&dl=1
2
0
516
2w
Spotlight Importer Extension Not Triggered for Custom UTI on macOS
Hi all, I'm trying to add Spotlight support to a macOS app that handles custom virtual machine bundles with the .vpvm extension. I’ve followed the current documentation and used the modern CSImportExtension approach with a Spotlight Importer extension target. Here’s what I’ve done: App Info.plist: Declared com.makeprog.vpvm as a UTI conforming to com.apple.package. Registered it under UTExportedTypeDeclarations and CFBundleDocumentTypes. Spotlight Importer Extension: Added a new macOS target using the Spotlight Import Extension template. Set the NSExtensionPointIdentifier to com.apple.spotlight.import. Used CSSupportedContentTypes = com.makeprog.vpvm. Implemented a minimal update(_ attributes:forFileAt:) method that sets displayName, title, and contentDescription. Other steps: Verified that the .appex is embedded under Contents/PlugIns/. Confirmed it appears in mdimport -e output with correct UTI. Used mdimport -m -d2 -t /path/to/file.vpvm, but I still get: Imported '/path/to/file.vpvm' of type 'com.makeprog.vpvm' with no plugIn. The extension is never invoked. I’ve also tried: Ensuring the .vpvm file is a valid directory bundle. Restarting Spotlight / rebuilding index. Ensuring the app and extension are properly signed. Tried installing the app in test virtual machine Question: Has anyone successfully used CSImportExtension for custom UTIs? Is there something additional I need to do for the extension to be recognized and triggered? Any advice or examples would be greatly appreciated! Thanks in advance.
3
1
178
2w
Request: Restore Launchpad Functionality or Allow Customizable App Organization in macOS Tahoe
With macOS Tahoe, Launchpad has been replaced by an App Library–style mode within Spotlight. While the alleged intention is UX consistency across the Apple ecosystem, the result is both a catastrophic usability regression and a radical break in consistency with iOS and iPadOS. Predefined App Library categorization is functionally incoherent: On iOS and now macOS, Apple’s predefined App Library categories place apps with seemingly identical functionality into unrelated groups—for example, 3D scanning tools scattered across Education, Utilities, and Productivity. Instead of making apps easier to find, this effectively creates a labyrinth that users must traverse to locate apps whose names and icons they may not recall. However Apple defines its app categories, they are not only inconsistent but also hopelessly inadequate for the long tail of real-world applications and user workflows. Loss of user control: Launchpad enabled users to group and organize applications according to their workflows. This aligns with Apple’s own Human Interface Guidelines, which emphasize user control, discoverability, and predictable behavior. The new Spotlight interface removes that flexibility, locking users into predefined categories that both impede and mislead—and cannot be overridden. Consistency across platforms is broken: If the goal was to unify iOS, iPadOS, and macOS, this approach actually undermines consistency. On iOS and iPadOS, users can still rely on a customizable Home Screen—a Launchpad-like experience—as their primary way of launching apps. In Tahoe, that option has been removed. macOS now forces users to depend exclusively on Spotlight with App Library categories, while eliminating the very feature that was consistent across platforms. Catastrophic impact on my workflow: As an interdisciplinary artist working in 2D, 3D, and time-based media, as well as coding, I make extensive use of a constantly changing array of AI tools and experiment with many new apps and web services, which I often turn into Web Apps. I cannot possibly recall the names of every native and web app on my system. I need predictable access to groups of related tools. Tahoe’s new auto-categories split those apps apart arbitrarily, slowing me down and interrupting established workflows, forcing me to navigate the aforementioned labyrinth just to find what I need. Proposal: A constructive way forward High-level objective: Simply restore Launchpad—or restore the ability to customize app categories/folders and manually assign apps to them, overriding or augmenting the predefined categories. This ensures users can launch apps according to their workflow, without needing to remember exact names or icons. Possible solutions: Allow manual subfolders within Applications, represented hierarchically in Spotlight. Provide a fullscreen Launchpad-like organizer (with uninstall via long-click, etc.), either as a replacement or toggleable option. Retain Apple’s auto-categories for those who prefer them, but let users override or augment them with their own. In summary: Tahoe eliminates a working, consistent paradigm (Launchpad/Home Screen) and forces reliance on an App Library system that categorizes poorly and cannot be customized. This is both a step backwards in functionality and a break in cross-platform consistency. A constructive solution is to restore Launchpad—or at least restore the ability for users to organize apps in ways that fit their workflows.
0
2
95
2w
Search Bar Should Be at the Top (Consistency Matters)
In iOS 18 betas, the App Store search bar has been moved to the bottom of the screen. This breaks years of usability and is inconsistent with Apple’s own apps—Calendar, Reminders, Maps, Safari, Files, Wallet, and Shortcuts—all of which keep search at the top. I (and many others) hold the phone in one hand and tap with the other. Top placement is faster, more natural, and aligns with established Apple design. The “thumb reach” argument does not fit real-world usage for a large portion of users. What I want is consistency across all Apple apps: put the search bar at the top everywhere. Apple already made this mistake with Safari’s bottom address bar in iOS 15 and had to add a toggle after backlash. Please don’t repeat history. Feedback ID: FB19598638 If you agree, please follow your own feedback and reference this thread. The more reports Apple sees, the more likely this gets fixed.
0
0
34
Aug ’25
Does Core Spotlight work with document-based apps?
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.
7
0
145
Jul ’25
How to donate IndexedEntity, if required in iOS 26
In the Get to Know App Intents WWDC session, it was said New this year, you can now add Spotlight indexing keys directly on properties. Annotating properties allows Spotlight to show more relevant information to customers. When donating indexed entities, the framework will handle creating the searchable item and attribute set for you. After donating entities, they can be found in Spotlight. How do you donate indexed app entities? Making app entities available in Spotlight seems to state it's not necessary to donate entities: The system can automatically extract the keys for Spotlight indexing at compile time and store them in the App Intents metadata that Xcode generates as part of your app’s bundle. As a result, Spotlight indexing is faster and can find your app entities without launching your app, and without you having to explicitly donate the entities to Spotlight. You also don’t need to manually update or remove entities from the Spotlight index when your app’s data changes. Say I have a CarEntity. The user can create/update/delete cars at any time. What is the modern way to get cars to appear in Spotlight in iOS 26?
2
0
122
Jun ’25
Core Spotlight searching only for title
I just adding a way to donate my app's data to Core Spotlight using CSSearchableIndex, but I'm finding that spotlight is only searching for the title of the CSSearchableItem I create. I know the index is working, because it always finds the item through the title property, but nothing else. This is how I'm creating the CSSearchableItem: - (CSSearchableItem *) createSearchableItem { CSSearchableItemAttributeSet* attributeSet = [[CSSearchableItemAttributeSet alloc] initWithContentType: UTTypeText]; attributeSet.title = [self titleForIndex]; attributeSet.displayName = [self titleForIndex]; attributeSet.contentDescription = [self contentDescriptionForIndex]; attributeSet.thumbnailData = [self thumbnailDataForIndex]; attributeSet.textContent = [self contentDescriptionForIndex]; CSSearchableItem *item = [[CSSearchableItem alloc] initWithUniqueIdentifier: [self referenceURLString] domainIdentifier:@"com.cjournal.cjournal-Logs" attributeSet:attributeSet]; item.expirationDate = [NSDate distantFuture]; return item; } There's a lot of confusing tips around which say specifying the 'textContent' should work, and/or setting the displayName is essential, but none of these are working. Is there something I'm missing with my setup? Thanks.
0
0
86
Jun ’25
onContinueUserActivity(CSSearchableItemActionType, perform) does not work on a SwiftUI macOS app
onContinueUserActivity(CSSearchableItemActionType, perform) works as expected on iOS when we search and select an item from Spotlight, but nothing happens when we do the same on a SwiftUI macOS app. var body: some Scene { WindowGroup { MyView() .onContinueUserActivity(CSSearchableItemActionType, perform: handleSpotlight) } } func handleSpotlight(_ userActivity: NSUserActivity) { // Is not called... } How can we respond to a user clicking a Spotlight result from our apps on macOS?
2
1
769
May ’25
Importing pictures with non-QT metadata
Movies taken with Android phones store their location metadata (and probably others) in ways that are ignored by Apple's ecosystem (QuickTime Player, Photos.app). I am considering creating a Spotlight importer so that this metadata is available to the sytem. But I have a couple of questions: Can a Spotlight importer add new data (like location) to the data that the standard importer already captured? Or would the new importer need to take over the whole data gathering? If so, would macOS allow that? Would that Spotlight importer be somehow used by e.g. Photos.app and QT Player to capture the location? Or would this end up in Spotlight "knowing" the location but Photos.app ignoring it? If so, maybe there is something more broadly useful than a Spotlight importer?
2
0
60
May ’25
Spotlight search by keywords setuped in NSUserActivity doesn't work
Hey there! I faced issue in iOS 18 and newer when Spotlight search doesn't show my App in results. In older versions it works. Here is my code: func configureUserActivitity(with id: String, keywords: [String]) { let activity = NSUserActivity(activityType: id) activity.contentAttributeSet = self.defaultAttributeSet activity.isEligibleForSearch = true activity.keywords = Set(keywords) activity.becomeCurrent() self.userActivity = activity } I didn't find any reasons why it doesn't work now. Maybe I should report a bug?
6
0
151
Apr ’25
How to debug a CoreSpotlight extension?
My CoreSpotlight extension seems to exceed the 6 MB memory limit. What’s the best way to debug this? I've tried to attach the debugger on the Simulator but the extension seems to be never launched when I trigger the reindex from Developer settings. Is this supposed to work? On device, I am able to attach the debugger. However, I can neither transfer the debug session to Instruments, nor display the memory graph. So I've no idea how the memory is used. Any recommendations how to move forward? Is there a way to temporarily disable the memory limit since even with LLDB attached, the extension is killed.
0
1
70
Apr ’25
Return the results of a Spotlight query synchronously from a Swift function
How can I return the results of a Spotlight query synchronously from a Swift function? I want to return a [String] that contains the items that match the query, one item per array element. I specifically want to find all data for Spotlight items in the /Applications folder that have a kMDItemAppStoreAdamID (if there is a better predicate than kMDItemAppStoreAdamID > 0, please let me know). The following should be the correct query: let query = NSMetadataQuery() query.predicate = NSPredicate(format: "kMDItemAppStoreAdamID > 0") query.searchScopes = ["/Applications"] I would like to do this for code that can run on macOS 10.13+, which precludes using Swift Concurrency. My project already uses the latest PromiseKit, so I assume that the solution should use that. A bonus solution using Swift Concurrency wouldn't hurt as I will probably switch over sometime in the future, but won't be able to switch soon. I have written code that can retrieve the Spotlight data as the [String], but I don't know how to return it synchronously from a function; whatever I tried, the query hangs, presumably because I've called various run loop functions at the wrong places. In case it matters, the app is a macOS command-line app using Swift 5.7 & Swift Argument Parser 1.5.0. The Spotlight data will be output only as text to stdout & stderr, not to any Apple UI elements.
1
0
79
Apr ’25
Siri Shortcut Phrases iOS -17
I made a set of Siri Shortcuts in my app with the AppShortcutsProvider, and they each have a set of phrases. I can activate the shortcuts via Siri phrases or Spotlight search on iOS 18+, but not on iOS -17. I've checked the documentation and see that AppShortcutsProvider is supported from iOS 16+, so I don't understand why I can't view the shortcuts in Spotlight or activate them with Siri unless it's at least iOS 18. Any thoughts?
4
0
295
Mar ’25
CSSearchableItemAttributeSet is missing recordingYear
I'd like to set the recordingYear in my Spotlight File Importer extension but the property is missing from CSSearchableItemAttributeSet e.g. in the resulting in mdls I'd like to see: kMDItemRecordingYear = 2008; This would allow me to search in Finder by the recording year criteria. There is a recordingDate property and I tried setting it to Date that only has a year but it didn't work. It just resulted in this: kMDItemRecordingDate = "2008-01-01 00:00:00 +0000";
0
0
53
Mar ’25
How to use core spotlight ?
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 ?
3
0
190
Mar ’25
Spotlight services not fully stopping
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?
1
0
287
Feb ’25
Spotlight Search Broken with MacOS Sequoia 15.3.1
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.
1
0
388
Feb ’25