简体   繁体   English

Spotlight 搜索不适用于 mac 催化剂应用程序

[英]Spotlight search not working for mac catalyst apps

I've an iOS app that has spotlight search feature which allows user to search items from an app.我有一个 iOS 应用程序,它具有聚光灯搜索功能,允许用户从应用程序中搜索项目。 It works fine on iOS app它在 iOS 应用程序上运行良好在此处输入图像描述

I am in the process of migrating the app as a catalyst app, somehow the spotlight search on mac catalyst app is not working我正在将应用程序迁移为催化剂应用程序,不知何故,mac 催化剂应用程序上的聚光灯搜索不起作用

在此处输入图像描述

So far following things have been checked到目前为止,已经检查了以下内容

  • Spotlight search logic is working as expected, there are no errors Spotlight 搜索逻辑按预期工作,没有错误
  • Restarted Mac重新启动的 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没有在 stack-overflow 上注册以前的问题

Env: macOS 12.0.1环境:macOS 12.0.1

PS: I am unsure if it is related to specific to my code as it is working fine on iPad and iPhone devices. PS:我不确定它是否与我的代码相关,因为它在 iPad 和 iPhone 设备上运行良好。

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.")
                    }
}

Found the issue: Assign value to attributeSet.relatedUniqueIdentifier only from initializer发现问题: 仅从初始化程序将值分配给attributeSet.relatedUniqueIdentifier

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM