Spotlight search not working for mac catalyst apps

150 Views Asked by At

I've an iOS app that has spotlight search feature which allows user to search items from an app. It works fine on iOS app enter image description here

I am in the process of migrating the app as a catalyst app, somehow the spotlight search on mac catalyst app is not working

enter image description here

So far following things have been checked

  • Spotlight search logic is working as expected, there are no errors
  • Restarted Mac
  • Open catalyst app multiple times just to check if it is syncing with core spotlight and it is.
  • No previous issues registered on stack-overflow

Env: macOS 12.0.1

P.S: I am unsure if it is related to specific to my code as it is working fine on iPad and iPhone devices.

let attributeSet = CSSearchableItemAttributeSet(contentType: .content)
                    attributeSet.title = decodeItem.name
                    attributeSet.relatedUniqueIdentifier = decodeItem.id
                    attributeSet.url = URL.init(string: decodeItem.url)
                    
                    
                    let searchableItem = CSSearchableItem(uniqueIdentifier: decodeItem.id,
                                                          domainIdentifier: "com.xxx.xxxx",
                                                          attributeSet: attributeSet)
                    
searchableItems.append(searchableItem)

                      CSSearchableIndex.default().indexSearchableItems(searchableItems) { error in
                    if let error = error {
                        print("Issue indexing: \(error)")
                    } else {
                        print("Indexed.")
                    }
}
1

There are 1 best solutions below

1
user4150758 On

Found the issue: Assign value to attributeSet.relatedUniqueIdentifier only from initializer