0

My indexed data don't have a photo, so I don't want to show a photo, I only want the title and description: error

I have tried to set:

attributes.thumbnailData = nil

But it stil shows this blank image.

static func setupSearchableContentForSpotlight() {
    let realm = try! Realm(configuration:Constants.realmConfigration.wordsConfigration)
    var words: Results<Word>!
    words = realm.objects(Word.self)
    var searchableItems = [CSSearchableItem]()
    words?.forEach { word in
        let attributes = CSSearchableItemAttributeSet(itemContentType: kUTTypeData as String)
        attributes.title = word.defination
        attributes.contentDescription = word.meaning
        attributes.thumbnailData = nil
        let searchableVegetable = CSSearchableItem(uniqueIdentifier: nil, domainIdentifier: nil, attributeSet: attributes)
    }
    CSSearchableIndex.default().indexSearchableItems(searchableItems) { (error) -> Void in
        print("indxing completed")
        UserDefaults.standard.set(true, forKey: "spotLightIndexed")
        if let error = error  {
            print(error.localizedDescription)
        }
    }
}

I expect to for example the result to be with only:

exams

الماس

without this blank image. note: the app already has display icons.

FarouK
  • 740
  • 6
  • 17
  • It should show your app icon - You must be missing a size from your icons. https://makeappicon.com/ios9icon – Paulw11 May 05 '19 at 00:40

2 Answers2

0

An image is always shown next to a Core Spotlight result. If you don't supply a thumbnail image, then iOS will show your app icon.

Ensure that you have the right size icons in your icon set. You need a 40x40 icon at standard, 2x and 3x resolutions.

Paulw11
  • 108,386
  • 14
  • 159
  • 186
  • As I said, all of the icons are included. – FarouK May 05 '19 at 00:54
  • You should definitely double check and ensure that they don't have any alpha channels. iOS isn't finding the relevant icon. – Paulw11 May 05 '19 at 00:55
  • Now I restarted my iPhone and the app icon is showing correctly next to the results, what a strange thing. thank you. – FarouK May 05 '19 at 00:56
0

The problem solved by restarting my iPhone.

Extra tip: if you are dealing with CoreSpotlight, restaurant your iPhone after significant changes.

FarouK
  • 740
  • 6
  • 17