Can app name for iOS Search be different than CFBundleDisplayName?

931 Views Asked by At

I have an app called "French Translator +" in the app store.

There is not enough space below the app icon to display the entire name so I set CFBundleDisplayName = "Translator +".

However, when I type "French" in iOS Search, my app doesn't appear in the results of the section for APPLICATIONS.

How can I get iOS Search to index "French Translator +" while displaying "Translator +" below the app icon?

enter image description here

2

There are 2 best solutions below

1
On

The question is already answered in Specify Spotlight keywords iOS 9

As you point out, Core Spotlight indexes data in the app. Data that you provide. So all you need to do is provide it with some data so Spotlight Search can find your app.

Adding this to application(_:didFinishLaunchingWithOptions:) worked for me:

let attributeSet = CSSearchableItemAttributeSet(itemContentType: "application")
attributeSet.title = "French Translator"
attributeSet.keywords = ["french", "translation", "translator"]
attributeSet.contentDescription = "French Language Translation App"

let item = CSSearchableItem(uniqueIdentifier: "5C0B7719-3BE7-4441-892D-A786AA431BDD", domainIdentifier: nil, attributeSet: attributeSet)
CSSearchableIndex.default().indexSearchableItems([item]) {
  print("Finished indexing with \(String(describing: $0))")
}
0
On

I found that the title and keywords are invalid at some point. And this works for me.

        let attributeSet = CSSearchableItemAttributeSet(contentType: .text)
        attributeSet.displayName = "Name"
        attributeSet.contentDescription = "Descruption"
        attributeSet.artist = "Lucas"

        let searchableItem = CSSearchableItem(uniqueIdentifier: "starWar", domainIdentifier: "com.fatbobman.Movies.Sci-fi", attributeSet: attributeSet)

        CSSearchableIndex.default().indexSearchableItems([searchableItem]){ error in
            if let error = error {
                print(error.localizedDescription)
            }
        }