I have created a Spotlight extension in iOS and want to debug it. However, since the Spotlight index is controlled by iOS I don't know which app will trigger an indexing run. I tried Safari but to no avail.
Select the Spotlight extension in the scheme selector in the top left of the Xcode window.
When you click on run, Xcode will ask you which app you want to run. Select your extension's parent app. This will run your app as normal but you will now be attached to the extension for debugging.
The next step is to trigger a Spotlight reindex. Do this from your device's settings page (it must be enabled for development from Xcode):
Settings -> Developer -> CoreSpotlight testing
Here you can select Reindex All Items or Reindex All Items With Identifiers. These two options correspond to the Core Spotlight IndexRequestHandler: CSIndexExtensionRequestHandler
methods below:
override func searchableIndex(_ searchableIndex: CSSearchableIndex, reindexAllSearchableItemsWithAcknowledgementHandler acknowledgementHandler: @escaping () -> Void) {
// Reindex all data with the provided index
}
override func searchableIndex(_ searchableIndex: CSSearchableIndex, reindexSearchableItemsWithIdentifiers identifiers: [String], acknowledgementHandler: @escaping () -> Void) {
// Reindex any items with the given identifiers
}
You will now be able to debug these methods as normal, with runtime errors displayed in the source editor.
© 2022 - 2024 — McMap. All rights reserved.