Hey Readers, hope you have a great time reading the posts, today we will have a quick look at Spotlight search feature of iOS 9. Spotlight Search is new feature of iOS9 which enables us to provide content search of our Application to the Spotlight API.

By implementing spotlight user can search content in our without even opening our app. So are you ready for the Spotlight search drive ? Lets begin.

Step 1 :
Add following frameworks to

  • CoreSpotlight Framework
  • Mobile Core Service Framework

Screen Shot 2015-10-13 at 7.15.57 pm

Step 2 :

Add following code to your view file.

CSSearchableItemAttributeSet *attributeSet;
    attributeSet = [[CSSearchableItemAttributeSet alloc]
                    initWithItemContentType:(NSString *)kUTTypeImage];
    attributeSet.title = @"Bhumesh";
    attributeSet.contentDescription = @"Super Spidy";
    attributeSet.keywords = @[@"bhumesh", @"spiderman",@"spidy"];
    UIImage *image = [UIImage imageNamed:@"spidy"];
    NSData *imageData = [NSData dataWithData:UIImagePNGRepresentation(image)];
    attributeSet.thumbnailData = imageData;
    CSSearchableItem *item = [[CSSearchableItem alloc]
    [[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[item]
                                                   completionHandler: ^(NSError * __nullable error) {
                                                       if (!error)
                                                           NSLog(@"Search item indexed");

Here make sure you supply your app bundle name “com.mybundle.SpotliteSearch” and proper keywords and you are good to go.

Run your project press control + shift + h and search you will see following search results except image as you need to add image to your results too.

Simulator Screen Shot 13-Oct-2015 7.29.15 pm

Hope this article helps :)


Credits : Bhumesh & Nirzar

Implementing Spotlight in YOUR App

Aadil Keshwani

People call me geek i call myself Coder. I like to explore & learn new things, R&D and Innovation motivates me. By profession i am iPhone Developer but i have sound knowledge of PhoneGap, HTML, CSS3, WordPress, Photoshop, PHP, CodeIgniter, OpenCart. Feel free to contact me for any queries or help in above technologies, i would be more than happy to help you out.

Category: Uncategorized