Skip to content

CoreSpotlight iOS xcode16.0 b1

Rolf Bjarne Kvinge edited this page Jul 11, 2024 · 4 revisions

#CoreSpotlight.framework https://github.com/xamarin/xamarin-macios/pull/20866

diff -ruN /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchQuery.h /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchQuery.h
--- /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchQuery.h	2024-04-19 07:52:52
+++ /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchQuery.h	2024-05-31 06:52:15
@@ -45,7 +45,7 @@
 
 // queryString: The query string (e.g., 'contentType == "public.email-message" && subject != "Re:*"')
 // attributes: The attributes to be fetched for the searchable items
-- (instancetype)initWithQueryString:(NSString *)queryString attributes:(NSArray<NSString *> * _Nullable)attributes;
+- (instancetype)initWithQueryString:(NSString *)queryString attributes:(NSArray<NSString *> * _Nullable)attributes NS_DEPRECATED(10_13, 13_0, 10_0, 16_0, "Use initWithQueryString:queryContext instead");
 
 @property (readonly, getter=isCancelled) BOOL cancelled;
 
diff -ruN /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchableIndex.h /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchableIndex.h
--- /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchableIndex.h	2024-04-05 22:57:38
+++ /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchableIndex.h	2024-06-01 03:25:45
@@ -20,6 +20,7 @@
     CSIndexErrorCodeRemoteConnectionError =                   -1003, //There was an error trying to communicate with the remote process
     CSIndexErrorCodeQuotaExceeded =                           -1004, //Quota for bundle was exceeded
     CSIndexErrorCodeIndexingUnsupported =                     -1005, //Indexing isn't supported on this device
+    CSIndexErrorCodeMismatchedClientState =                   -1006, //The expected client state did not match the indexed one.
 } CS_AVAILABLE(10_13, 9_0) CS_TVOS_UNAVAILABLE;
 
 @protocol CSSearchableIndexDelegate;
@@ -38,7 +39,7 @@
 // Apps can set a name for the index instance. This name is used as a handle for the client state used with the batch API, allowing a single client to have multiple client states; you have to retrieve the client state for an index instance with the same name as you used when setting the client state.
 - (instancetype)initWithName:(NSString *)name;
 
-//Apps can set a default protection class for items in their entitlements.  You can alternately create an instance with a custom protection class to use on iOS.  It should be one of NSFileProtectionComplete, NSFileProtectionCompleteUnlessOpen, or NSFileProtectionCompleteUntilFirstUserAuthentication.
+// Apps can set a default protection class for items in their entitlements.  You can alternately create an instance with a custom protection class to use on iOS.  It should be one of NSFileProtectionComplete, NSFileProtectionCompleteUnlessOpen, or NSFileProtectionCompleteUntilFirstUserAuthentication.
 - (instancetype)initWithName:(NSString *)name protectionClass:(nullable NSFileProtectionType)protectionClass;
 
 // Call this method to add or update items in the index.
@@ -65,23 +66,24 @@
 CS_TVOS_UNAVAILABLE
 @interface CSSearchableIndex (CSOptionalBatching)
 
-//Batching:
+// Batching:
 
-//For some clients, it may be beneficial to batch updates to the index.  Those clients can use batching and persist client state information (< 250 bytes) in the index.  That state information can be used to determine where indexing needs to resume from in case of a client crash or jetsam. Batching is supported for indexSearchableItems deleteSearchableItemsWithIdentifiers.  Persisted client state will be reset whenever deleteAllSearchableItemsWithCompletionHandler is called.
+// For some clients, it may be beneficial to batch updates to the index.  Those clients can use batching and persist client state information (< 250 bytes) in the index.  That state information can be used to determine where indexing needs to resume from in case of a client crash or jetsam. Batching is supported for indexSearchableItems deleteSearchableItemsWithIdentifiers.  Persisted client state will be reset whenever deleteAllSearchableItemsWithCompletionHandler is called.
 
-//Note: Batching is unsupported for the CSSearchableIndex returned by the defaultSearchableIndex method
+// Note: Batching is unsupported for the CSSearchableIndex returned by the defaultSearchableIndex method
 
-//Thread safety: In batch mode, the client takes responsibility for protecting the private CSSearchableIndex instance from concurrent access from multiple threads. Concurrent calls to the index instance will have undefined results. beginIndexBatch must not be called again before endIndexBatchWithClientState:completionHandler: has returned (it is however safe to call before the completionHandler passed to endIndexBatchWithClientState:completionHandler has been called).
+// Thread safety: In batch mode, the client takes responsibility for protecting the private CSSearchableIndex instance from concurrent access from multiple threads. Concurrent calls to the index instance will have undefined results. beginIndexBatch must not be called again before endIndexBatchWithClientState:completionHandler: has returned (it is however safe to call before the completionHandler passed to endIndexBatchWithClientState:completionHandler has been called).
 
 
-//Begin a batch of index adds, updates, or deletes.
+// Begin a batch of index adds, updates, or deletes.
 - (void)beginIndexBatch;
 
-//End a batch passing in client state information to be persisted in the index.  The completion handler will be called once the client state has been persisted.
+// End a batch passing in expected client state information to be persisted in the index, along with new client state for the current batch. The completion handler will be called once the client state has been persisted. If the client state does not match expected, an error of CSIndexErrorCodeMismatchedClientState will be returned.
+- (void)endIndexBatchWithExpectedClientState:(nullable NSData *)expectedClientState newClientState:(NSData *)newClientState completionHandler:(void (^ __nullable)(NSError * __nullable error))completionHandler NS_SWIFT_NAME(endIndexBatch(expectedClientState:newClientState:completionHandler:)) API_AVAILABLE(macos(15.0), ios(18.0));
+
+// End a batch passing in client state information to be persisted in the index. The completion handler will be called once the client state has been persisted.
 - (void)endIndexBatchWithClientState:(NSData *)clientState completionHandler:(void (^ __nullable)(NSError * __nullable error))completionHandler;
 
-
-
 // Async fetches the app's last stored client state information.
 - (void)fetchLastClientStateWithCompletionHandler:(void (^)(NSData * __nullable clientState,NSError * __nullable error))completionHandler;
 
@@ -101,13 +103,13 @@
 CS_AVAILABLE(14_0, 17_0)
 CS_TVOS_UNAVAILABLE
 @interface CSSearchableIndex (CSOptionalBatchingWithExpectedState)
-//End a batch passing in client state information to be persisted in the index. The completion handler will be called with an error, and the new state will not be persisted, if the expectedClientState does not match the client state currently stored in the index. Otherwise, the completion handler will be called once the client state has been persisted.
+// End a batch passing in client state information to be persisted in the index. The completion handler will be called with an error, and the new state will not be persisted, if the expectedClientState does not match the client state currently stored in the index. Otherwise, the completion handler will be called once the client state has been persisted.
 
 @end
 
 
-//An application that is long running should provide a CSSearchableIndexDelegate conforming object to handle communication from the index.
-//Alternatively, an app can provide an extension whose request handler conforms to this protocol and the extension will be called if the app isn't running.
+// An application that is long running should provide a CSSearchableIndexDelegate conforming object to handle communication from the index.
+// Alternatively, an app can provide an extension whose request handler conforms to this protocol and the extension will be called if the app isn't running.
 CS_AVAILABLE(10_13, 9_0)
 CS_TVOS_UNAVAILABLE
 @protocol CSSearchableIndexDelegate <NSObject>
@@ -131,15 +133,15 @@
 
 @optional
 
-//When on battery power, it is possible for indexing to slowed down to prevent battery drain.
-//The developer may want to optionally implement these methods to receive notice that indexing is being throttled and react accordingly (e.g. by priortizing indexing of more important content).
+// When on battery power, it is possible for indexing to slowed down to prevent battery drain.
+// The developer may want to optionally implement these methods to receive notice that indexing is being throttled and react accordingly (e.g. by priortizing indexing of more important content).
 - (void)searchableIndexDidThrottle:(CSSearchableIndex *)searchableIndex;
 - (void)searchableIndexDidFinishThrottle:(CSSearchableIndex *)searchableIndex;
 
-// The developer may provided a NSData representation if type was specified in providerDataTypeIdentifiers property.
+// The developer may provide a NSData representation if type was specified in providerDataTypeIdentifiers property.
 - (nullable NSData *)dataForSearchableIndex:(CSSearchableIndex *)searchableIndex itemIdentifier:(NSString *)itemIdentifier typeIdentifier:(NSString *)typeIdentifier error:(out NSError ** __nullable)outError CS_AVAILABLE(10_13, 11_0) CS_TVOS_UNAVAILABLE;
 
-// The developer may provided a NSURL to file representation representation if type was specified from providerDataTypeIdentifiers or providerInPlaceFileTypeIdentifiers property.
+// The developer may provide a NSURL to file representation representation if type was specified from providerDataTypeIdentifiers or providerInPlaceFileTypeIdentifiers property.
 - (nullable NSURL *)fileURLForSearchableIndex:(CSSearchableIndex *)searchableIndex itemIdentifier:(NSString *)itemIdentifier typeIdentifier:(NSString *)typeIdentifier inPlace:(BOOL)inPlace error:(out NSError ** __nullable)outError CS_AVAILABLE(10_13, 11_0) CS_TVOS_UNAVAILABLE;
 
 @end
diff -ruN /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchableItem.h /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchableItem.h
--- /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchableItem.h	2024-04-19 07:52:52
+++ /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchableItem.h	2024-05-31 07:04:11
@@ -38,7 +38,9 @@
 CS_TVOS_UNAVAILABLE
 @interface CSSearchableItem : NSObject <NSSecureCoding, NSCopying>
 
-- (instancetype)initWithUniqueIdentifier:(nullable NSString *)uniqueIdentifier //Can be null, one will be generated
+// uniqueIdentifier can be null, in which case one will be generated.
+// If passing in null, you must retrieve and store the generated identifier in persistent storage, so that you can open the appropriate item when recalled in a query
+- (instancetype)initWithUniqueIdentifier:(nullable NSString *)uniqueIdentifier
                         domainIdentifier:(nullable NSString *)domainIdentifier
                             attributeSet:(CSSearchableItemAttributeSet *)attributeSet;
 
@@ -63,6 +65,11 @@
 // Set of attributes containing meta data for the item
 @property (strong) CSSearchableItemAttributeSet *attributeSet;
 
+// A flag to specify whether or not this item should be treated as an update
+// By default index insertions are treated as a full delete of any existing item, followed by an insert, and the client needs to specify whether or not this should be treated as an update.
+// If an item is marked as an update, but does not already exist in the index, it will be dropped during the attempted indexing.
+// In update mode, attributes can be marked as deleted by setting their value to nil.
+@property (assign) BOOL isUpdate API_AVAILABLE(macos(10.11), ios(9.0)) CS_TVOS_UNAVAILABLE;
 @end
 
 NS_ASSUME_NONNULL_END
diff -ruN /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchableItemAttributeSet_Messaging.h /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchableItemAttributeSet_Messaging.h
--- /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchableItemAttributeSet_Messaging.h	2024-04-05 22:41:38
+++ /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSSearchableItemAttributeSet_Messaging.h	2024-05-31 07:04:11
@@ -66,7 +66,7 @@
 //(This is always the email address, and not the human readable version)
 @property(nullable, copy) NSArray<NSString*> *authorEmailAddresses;
 
-//This attribute indicates the reciepients email addresses.
+//This attribute indicates the recipients email addresses.
 //(This is always the email address,  and not the human readable version).
 @property(nullable, copy) NSArray<NSString*> *recipientEmailAddresses;
 
diff -ruN /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSUserQuery.h /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSUserQuery.h
--- /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSUserQuery.h	2024-04-19 07:52:52
+++ /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreSpotlight.framework/Headers/CSUserQuery.h	2024-05-31 06:52:15
@@ -11,6 +11,13 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
+API_AVAILABLE(macos(15.0), ios(18.0)) CS_TVOS_UNAVAILABLE
+typedef NS_ENUM(NSInteger, CSUserInteraction) {
+    CSUserInteractionSelect,
+    CSUserInteractionDefault=CSUserInteractionSelect,
+    CSUserInteractionFocus,
+} NS_SWIFT_NAME(CSUserQuery.UserInteractionKind);
+
 API_AVAILABLE(macos(13.0), ios(16.0)) CS_TVOS_UNAVAILABLE
 @interface CSUserQueryContext : CSSearchQueryContext
 
@@ -18,18 +25,28 @@
 + (CSUserQueryContext *)userQueryContextWithCurrentSuggestion:(CSSuggestion * _Nullable)currentSuggestion;
 
 @property (nonatomic, assign) BOOL enableRankedResults;
+@property (nonatomic, assign) BOOL disableSemanticSearch API_AVAILABLE(macos(15.0), ios(18.0));
 
 // maxResultCount is maximum number of search results to retrieve. (defaults to 0)
 // If maxResultCount == 0, Spotlight will retrieve all results related to query. (committed search)
 @property (nonatomic, assign) NSInteger maxResultCount;
+
 // maxSuggestionCount is maximum number of suggestion results to retrieve. (defaults to 0)
 @property (nonatomic, assign) NSInteger maxSuggestionCount;
 
+// maxRankedResultCount is maximum number of ranked search results to retrieve. (defaults to 100)
+// If maxRankedResultCount > maxResultCount, Spotlight will rank maxResultCount results related to query.
+@property (nonatomic, assign) NSInteger maxRankedResultCount API_AVAILABLE(macos(15.0), ios(18.0));
+
 @end
 
 API_AVAILABLE(macos(13.0), ios(16.0)) CS_TVOS_UNAVAILABLE
 @interface CSUserQuery : CSSearchQuery
 
++ (void)prepare API_AVAILABLE(macos(15.0), ios(18.0));
+
++ (void)prepareProtectionClasses:(NSArray<NSFileProtectionType> *)protectionClasses API_AVAILABLE(macos(15.0), ios(18.0));
+
 - (instancetype)initWithUserQueryString:(NSString * _Nullable)userQueryString userQueryContext:(CSUserQueryContext * _Nullable)userQueryContext NS_DESIGNATED_INITIALIZER;
 
 // The query will update the count before each foundSuggestionsHandler invocation to reflect
@@ -39,6 +56,10 @@
 // The foundSuggestionsHandler may be invoked additional times as new suggestions are generated,
 // but the value will always be a complete, ordered list. The query serializes all the foundSuggestionsHandler invocations. If no handler is set, suggestions will not be generated.
 @property (nullable, copy) void (^foundSuggestionsHandler)(NSArray<CSSuggestion *> *suggestions);
+
+- (void)userEngagedWithItem:(CSSearchableItem *)item visibleItems:(NSArray<CSSearchableItem *> *)visibleItems userInteractionType:(CSUserInteraction)userInteractionType NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(15.0), ios(18.0));
+
+- (void)userEngagedWithSuggestion:(CSSuggestion *)suggestion visibleSuggestions:(NSArray<CSSuggestion *> *)visibleSuggestions userInteractionType:(CSUserInteraction)userInteractionType NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(15.0), ios(18.0));
 
 - (void)start;
 - (void)cancel;
Clone this wiki locally