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

Add a strong reference to the NSUserActivity works for me! Thanks!

It seems like all reports of NSUserActivity working on the forums are in fact people seeing results reported by the Core Spotlight. There are a number of reports (in here and the bug reports) of NSUserActivity indexing not working.


I've followed instructions to the letter and I still don't get any results. Is there a simple example project somewhere that demonstrates the NSUserActivity actually working as advertised?

As I've mentioned before, the best thing to do is get a bug report filed with a sample project so we can take a look at what you're doing and why it's not working for you. Please post your bug number when you've filed it.

I finally figured out why NSUserActivity wasn't working for me!


One of the values I stored in the userInfo dictionary was a CLLocation. This caused the whole userInfo to be silently ignored and the NSUserActivity not shown.


Thank you for your help.

I'd love it if you'd file a bug report saying that you got no failure indication in this case (and you effectively wasted your time having to track it down manually). Having things get silently ignored is not helpful and I would consider it a bug (at least in a debug setting). Would you be willing to do that and post a bug number so I can track it?

I have now filed a bug report #22521824 with clear instructions on how to reproduce the issue. Unfortunately I don't have the resources to create an example project that reproduces the problem, so this is the best I can do.

Thank you for this bug report. I certainly agree that we should provide some better feedback here (even if only at compile time). To be clear, though, the documentation does clarify that what you're doing by specifying a CLLocation value in the userInfo is unsupported:


Each key and value must be of the following types:

NSArray
,
NSData
,
NSDate
,
NSDictionary
,
NSNull
,
NSNumber
,
NSSet
,
NSString
, or
NSURL
. The system may translate file scheme URLs that refer to iCloud documents to valid file URLs on a continuing device.


Doesn't mean we can't be more helpful, but you need to change your code regardless.

I have added NSUseractivity. But I don't have Hand off feature on my app. It seems without Hand off Apple doesn't accept apps. Anyone has an idea?