Verifying Search APIs are working?

I'm attempting to implement the latest search APIs in our app.


From following the code samples, I've done most of the implementation. Is there a way to verify the result, either on the simulator or on device?


I don't see any sample projects other than the sample code on the site and in the presentation - so I'm not sure if I'm missing anything in the implementation.

Accepted Reply

For things like the NSUserActivity and CoreSpotlight APIs you should be able to add that code, run it on a device, then go into Search on your device and search for things like the keywords, description, or content you've added to the local device index. If something isn't showing up when you'd expect it to please file a bug report, preferably with a small sample project illustrating the issue.

Replies

The simulator does not support the new search features (just like it doesn't support Handoff). That's what I was told by at the WWDC 15 labs.


They also seemed to overlook the need for search item localization when putting the feature together.

For things like the NSUserActivity and CoreSpotlight APIs you should be able to add that code, run it on a device, then go into Search on your device and search for things like the keywords, description, or content you've added to the local device index. If something isn't showing up when you'd expect it to please file a bug report, preferably with a small sample project illustrating the issue.

Cool, seeing the results now, just not getting any thumbnail images in my results. I'm using CSSearchableItemAttributeSet and setting the thumbnail data, but only seeing the app icon. Any ideas?

As mentioned in the iOS 9 Release Notes, thumbnails and descriptions aren't showing up correctly in seed 1.

I user NSUserActivity added to search index, but I can not search the conent?

I create a NSUserActivity, set eligibleForSearch YES, and called [activity becomeCurrent].

but I can not search the content of activity. How did you see the results?

One thing that has bitten a few people (myself included) is that the activity must not be deallocated. If your code is only working with NSUserActivities (i.e. not using CoreSpotlight in addition) then make sure your activities aren't being deallocated immediately. In my case, I had code that was allocating the NSUA, setting some properties on it, calling becomeCurrent, but then the object would go out of scope and deallocated. If you're doing this, try tossing the activity into a strong property to see if you can then see the results when you search.


If you're unable to get it to work, please file a bug report and attach your project so we can take a look (and post your bug number here).

So is the expected behavior when using an NSUserActivity that it should be retained, otherwise the index goes away? That doesn't really make sense to me.


I just installed Beta 2, and now my search results are not showing up, nor are new results being added (same code as previous).


On my iPad with Beta 1, the results are still showing, and new results are added to the index.


Checking the release notes there's nothing indicating this is a known issue.


Just submitted a bug report (21544898, with sample app) to demonstrate the issue with Beta 2.

I'll be installing beta on a few other devices to verify for sure, but so far it's demonstrable on an iphone 5s and iphone 6

I'm seeing the same problem on beta 3. Has anybody gotten this to work?


I can get the NSUserActivity to work in handover, but I don't see any entries in the search results. I'm storing the activity into the userActivity property of the UIResponder.

Yes, there have been multiple reports of people getting NSUserActivity to work on the forums. You are setting the elegibleForSearch property to true, correct? By all means feel free to file a bug report and attach a sample project and we can take a look.

Hi everyone, i added NSUserActivityTypes to my Info.plist. Then i made my userActivity strong property of type NSUserActivity and next how was writing in documentation here and all works fine
My example.


UPDATE: Sorry, I was wrong, I haven't removed items after work with Core Spotlight and therefore it worked for me.

That's great, thanks for sharing! One very minor comment, you shouldn't need to include the self.person.fullName in the keywords set since it's the title of the activity.

It's still not working for me under beta 3. My bug report was closed as a duplicate.

What's your bug number? I didn't see it posted here in this thread.

So are you saying it doesn't work for you? (The results were just left over from spotlight?)

I was wrong - this turned out to be the uniqueIdentifier issue.