iossearchios9corespotlight

App search results not showing up in spot light iOS


I implemented App Search using CoreSpotLight framework. The results are still not showing up in iOS spotlight

The approach i followed is

  1. Created CSSearchableItemAttributeSet with title, keywords and contentDescription
  2. Created CSSearchableItem with above created attributes set.
  3. Added the CSSearchableItem to CSSearchableIndex

Every thing seems to be correct, not sure why the results are not showing up..


Solution

  • Finally managed to find the issue,

    The simulator ( iPad Retina 9.3 ) which i was using, is not supported for core spotlight. We can find the unsupported devices names in apple docs

    Although app search is available for iOS 9 users, the search functionality of NSUserActivity and Core Spotlight is not supported on iPhone 4s, iPad 2, iPad (3rd generation), iPad mini, and iPod touch (5th generation).

    Also, The following code was throwing an error

    [[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[item] completionHandler:^(NSError * _Nullable error) {
            if (error) {
                NSLog(@"Error :%@",error);
            }
     }];
    

    The log is Error : Error Domain=CSIndexErrorDomain Code=-1005 "(null)”, which means CSIndexErrorCodeIndexingUnsupported , Indexing isn't supported on this device. Hope this save time for someone.

    Edit

    As @rmaddy suggests, check for CSSearchableIndex isIndexingAvailable, this straightaways help to find the issue.