做了一个记录的 app ,用的 Core Data ,上个版本添加了 spotlight, 代码很简单
self.spotlightDelegate = StorageSpotlightDelegate(forStoreWith: description, coordinator: container.persistentStoreCoordinator) let isSpotlightDisable = UserDefaults.standard.bool(forKey: "isSpotlightDisable") if !isSpotlightDisable { self.toggleSpotlightIndexing(enable: true) } //MARK: - Spotlight extension CoreDataStack { public func toggleSpotlightIndexing(enable: Bool) { guard let spotlightDelegate = spotlightDelegate else { return } if enable { spotlightDelegate.startSpotlightIndexing() } else { spotlightDelegate.stopSpotlightIndexing() spotlightDelegate.deleteSpotlightIndex { error in if let error = error { print(error) } } } UserDefaults.standard.set(!enable, forKey: "isSpotlightDisable") } }
前几天做完,手机上安装 tf 版本后,随便搜了一下发现没问题就上线了。昨天又试了一次,发现搜不到了。 如果我新增一条记录,开始是可以搜到的,但是如果我停止索引后再次开启,就搜不到了。
起初我以为自己手机 iOS18.0 的原因,并有可能是升级导致的。所以我在测试机 iOS15 进行了两个测试
都无问题。
同时在我自己手机上,发现极光词典查单词,也会有无法搜索到的情况。
不知道有无大佬有解决办法