【问题标题】:Spotlight search not working for mac catalyst appsSpotlight 搜索不适用于 Mac 催化剂应用程序
【发布时间】:2022-01-25 12:36:07
【问题描述】:

我有一个 iOS 应用程序,它具有聚光灯搜索功能,允许用户从应用程序中搜索项目。它在 iOS 应用上运行良好

我正在将应用程序迁移为催化剂应用程序,不知何故,mac 催化剂应用程序上的聚光灯搜索不起作用

到目前为止,已经检查了以下内容

  • Spotlight 搜索逻辑按预期工作,没有错误
  • 重新启动的 Mac
  • 多次打开 Catalyst 应用,检查它是否与核心 Spotlight 同步。
  • 以前没有在 stack-overflow 上注册过问题

环境:macOS 12.0.1

P.S:我不确定它是否与我的代码相关,因为它在 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.")
                    }
}

【问题讨论】:

    标签: ios macos mac-catalyst spotlight corespotlight


    【解决方案1】:

    发现问题:仅从初始化程序为 attributeSet.relatedUniqueIdentifier 赋值

    【讨论】:

      猜你喜欢
      • 2021-10-18
      • 2022-08-17
      • 2019-11-29
      • 2021-04-07
      • 2020-12-14
      • 2023-04-02
      • 2013-03-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多