2

I have an App called App 1, I changed that name to App 2 on CFBundleDisplayName and I defined the the search keywords attributes as bellow:

if let displayName = Bundle.main.object(forInfoDictionaryKey: "CFBundleDisplayName") as? String {
     let attributeSet = CSSearchableItemAttributeSet(itemContentType: kUTTypeData as String)
     attributeSet.title = displayName
     attributeSet.contentDescription = ""
     attributeSet.keywords = ["App 1", "App 2"]
     let item = CSSearchableItem(uniqueIdentifier: "0", domainIdentifier: Bundle.main.bundleIdentifier, attributeSet: attributeSet)
     CSSearchableIndex.default().indexSearchableItems([item])
}

When I have the App 1 installed and I update it to App 2 the display name on the home screen is correct, App 2. But When I search for App 1 or App 2 on the Spotlight, the App always shows the old name App 1.

When the App is not installed on the device, and I install the new version App 2 everything works fine, the Spotlight shows the correct name.

Also, when I restart the device everything gets back to normal!

I m not sure how Spotlight works! But is there any cache or something to handle?

Dávid Pásztor
  • 51,403
  • 9
  • 85
  • 116
raed
  • 4,887
  • 4
  • 30
  • 49
  • You are setting the display name in spotlight, that will not update until this code runs again and updates the values – Scriptable Oct 08 '19 at 10:44
  • @Scriptable If you mean that closing the app and open it again will fix it, I tried that as well but it's not working! If not, could you please be more specific? – raed Oct 08 '19 at 10:48
  • I am saying that the code above needs to run in order to update anything in spotlight, that probably means running the app after update, but it may not work if the identifier and bundle identifier are not the same. are you planning on changing your apps name often when it goes live to the app store? otherwise this might not be an issue – Scriptable Oct 08 '19 at 10:56
  • I see, identifier and bundle identifier are the same I changed only CFBundleDisplayName. the code is running and it's located on AppDelegate. This is the first App name change in 4 years! – raed Oct 08 '19 at 11:07

0 Answers0