Skip to content

FileProvider macOS xcode16.0 b1

Rolf Bjarne Kvinge edited this page Jul 12, 2024 · 5 revisions

#FileProvider.framework https://github.com/xamarin/xamarin-macios/pull/20890

diff -ruN /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/FileProvider.h /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/FileProvider.h
--- /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/FileProvider.h	2024-04-14 19:02:35
+++ /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/FileProvider.h	2024-05-30 02:54:31
@@ -26,3 +26,4 @@
 #import <FileProvider/NSFileProviderRequest.h>
 #import <FileProvider/NSFileProviderReplicatedExtension.h>
 #import <FileProvider/NSFileProviderTesting.h>
+#import <FileProvider/NSFileProviderKnownFolders.h>
diff -ruN /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderDefines.h /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderDefines.h
--- /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderDefines.h	2024-04-14 19:02:36
+++ /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderDefines.h	2024-05-30 02:54:32
@@ -39,3 +39,10 @@
 #define FILEPROVIDER_API_AVAILABILITY_V6_0_IOS API_AVAILABLE(macos(14.1), ios(17.1)) API_UNAVAILABLE(watchos, tvos) API_UNAVAILABLE(macCatalyst)
 
 #define FILEPROVIDER_API_AVAILABILITY_V7_0_IOS API_AVAILABLE(macos(14.4), ios(17.4)) API_UNAVAILABLE(watchos, tvos) API_UNAVAILABLE(macCatalyst)
+
+#define FILEPROVIDER_API_AVAILABILITY_EXTERNAL_VOLUME API_AVAILABLE(macos(15.0)) API_UNAVAILABLE(watchos, tvos) API_UNAVAILABLE(ios, macCatalyst)
+
+// macOS API for support for known folders
+#define FILEPROVIDER_API_AVAILABILITY_DESKTOP API_AVAILABLE(macos(15.0)) API_UNAVAILABLE(watchos, tvos) API_UNAVAILABLE(ios, macCatalyst)
+
+#define FILEPROVIDER_API_AVAILABILITY_V8_0_IOS API_AVAILABLE(macos(15.0), ios(18.0)) API_UNAVAILABLE(watchos, tvos) API_UNAVAILABLE(macCatalyst)
diff -ruN /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderDomain.h /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderDomain.h
--- /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderDomain.h	2024-04-05 22:44:07
+++ /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderDomain.h	2024-05-30 10:38:20
@@ -8,7 +8,6 @@
 #import <Foundation/Foundation.h>
 #import <FileProvider/NSFileProviderExtension.h>
 
-
 NS_ASSUME_NONNULL_BEGIN
 
 FILEPROVIDER_API_AVAILABILITY_V2_V3
@@ -66,6 +65,15 @@
     NSFileProviderDomainTestingModeInteractive = 1 << 1
 } NS_SWIFT_NAME(NSFileProviderDomain.TestingModes);
 
+/** Specifying a list of known folders.
+ */
+FILEPROVIDER_API_AVAILABILITY_DESKTOP
+typedef NS_OPTIONS(NSUInteger, NSFileProviderKnownFolders) {
+    NSFileProviderDesktop = 1 << 0,
+
+    NSFileProviderDocuments = 1 << 1
+};
+
 /**
  File provider domain.
 
@@ -131,6 +139,19 @@
 - (instancetype)initWithIdentifier:(NSFileProviderDomainIdentifier)identifier displayName:(NSString *)displayName FILEPROVIDER_API_AVAILABILITY_V3_IOS;
 
 /**
+ Initialize a new replicated NSFileProviderDomain on a specific volume.
+
+ If a volumeURL is specified, and that volume is eligible, the domain will be located on this volume. The URL is used to designate a volume
+ but doesn't influence where on this volume is the domain going to be stored.
+
+ In order to avoid domainID collisions between volumes, the NSFileProviderDomainIdentifier of external domains are generated randomly by FileProvider.
+ The provider should therefore use domainUserInfo to associate all necessary information to map the created object to the corresponding account.
+ */
+- (instancetype)initWithDisplayName:(NSString *)displayName
+                           userInfo:(NSDictionary *)userInfo
+                          volumeURL:(nullable NSURL *)volumeURL FILEPROVIDER_API_AVAILABILITY_EXTERNAL_VOLUME;
+
+/**
  The identifier - as provided by the file provider extension.
  */
 @property (readonly, copy) NSFileProviderDomainIdentifier identifier;
@@ -226,6 +247,21 @@
  If the item is not fully materialized, the system will offer to permanently delete the item.
  */
 @property (readwrite, assign) BOOL supportsSyncingTrash FILEPROVIDER_API_AVAILABILITY_V5_0;
+
+@property (nonatomic, readonly, nullable) NSUUID *volumeUUID FILEPROVIDER_API_AVAILABILITY_EXTERNAL_VOLUME;
+
+/**
+ A dictionary set by the client app. Keys must be strings, values must be [String, Number, Date, Data]
+ */
+@property (nonatomic, readwrite, copy, nullable) NSDictionary *userInfo FILEPROVIDER_API_AVAILABILITY_EXTERNAL_VOLUME;
+
+/** List of known folders that are currently replicated by this domain.
+ */
+@property (readonly, assign) NSFileProviderKnownFolders replicatedKnownFolders FILEPROVIDER_API_AVAILABILITY_DESKTOP;
+
+/** List known folders that can be replicated by this domain.
+ */
+@property (readwrite, assign) NSFileProviderKnownFolders supportedKnownFolders FILEPROVIDER_API_AVAILABILITY_DESKTOP;
 
 @end
 
diff -ruN /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderKnownFolders.h /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderKnownFolders.h
--- /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderKnownFolders.h	1970-01-01 01:00:00
+++ /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderKnownFolders.h	2024-05-30 04:42:43
@@ -0,0 +1,140 @@
+//
+//  NSFileProviderKnownFolders.h
+//  FileProvider
+//
+//  Copyright © 2018-2024 Apple Inc. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+#import <FileProvider/NSFileProviderDefines.h>
+#import <FileProvider/NSFileProviderDomain.h>
+#import <FileProvider/NSFileProviderManager.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+#pragma mark - Defining Location
+
+/** Specify the location of a known folder in the replicated tree.
+ */
+FILEPROVIDER_API_AVAILABILITY_DESKTOP
+NS_SWIFT_NAME(NSFileProviderKnownFolderLocations.Location)
+@interface NSFileProviderKnownFolderLocation : NSObject
+
+/** Initialize a location with the filename of the folder in a specified parent.
+
+ When replicating a known folder the system will reuse a folder located at the specified
+ filename within the parent if one exists, or create a new item at this location if none
+ exists yet.
+ */
+- (instancetype)initWithParentItemIdentifier:(NSFileProviderItemIdentifier)parentItemIdentifier
+                                    filename:(NSString *)filename;
+
+/** Initialize a location with the item identifier of a folder that already exists on the server.
+
+ If the known folder already exists on the server, the provider can specify the exact identifier
+ of the item that needs to be used to back the known folder.
+ */
+- (instancetype)initWithExistingItemIdentifier:(NSFileProviderItemIdentifier)existingItemIdentifier;
+
+@end
+
+/** Specify the locations at which known folders should be synced in the replicated tree.
+
+ Desktop and Documents candidate items need to have the same parent folder.
+ */
+FILEPROVIDER_API_AVAILABILITY_DESKTOP
+@interface NSFileProviderKnownFolderLocations : NSObject
+
+/** Specify whether the system should create a binary compatibility symlink folders.
+
+ If YES, the system creates a symlink from the logical location of the folder in the domain
+ sync root to the known folder location. This symlink allows any app that would have hardcoded
+ the previous location of the folder to still work after enabling the feature.
+
+ Default value is YES.
+ */
+@property (readwrite, assign, nonatomic) BOOL shouldCreateBinaryCompatibilitySymlink;
+
+/** Candidate item for ~/Desktop
+
+    For user experience reasons, it is strongly recommended to name the target folder "Desktop".
+ */
+@property (readwrite, strong, nullable, nonatomic) NSFileProviderKnownFolderLocation *desktopLocation;
+
+/** Candidate item for ~/Documents
+
+ For user experience reasons, it is strongly recommended to name the target folder "Documents".
+ */
+@property (readwrite, strong, nullable, nonatomic) NSFileProviderKnownFolderLocation *documentsLocation;
+
+- (instancetype)init;
+@end
+
+#pragma mark - Claiming replication of known folders
+
+@interface NSFileProviderManager (KnownFolders)
+
+/** Request the specified known folders to be synced by this domain.
+
+ This method allows the provider to claim a set of known folders described by the non-null
+ properties of the knownFolders parameter. The system will only enable sync for those folders
+ in that domain if the set of locations is valid and if the user agrees.
+
+ This API should only be called as a result of the user requesting, via UI in the provider's application,
+ that they wish to start syncing the Desktop and Document folders.
+ If the provider chooses to implement a UI which invokes this API, the provider should also implement a UI
+ for the user to request to stop syncing the Desktop and Document folders,
+ using the `-[NSFileProviderManager releaseKnownFolders:localizedReason:completionHandler:]` method.
+
+ The reason specified in this call is a custom string that the provider can pass and will be
+ presented to the user as a way to explain why it is claiming those known folders. One suggested
+ phrasing would be:
+
+ > Keep your Desktop & Documents in sync with <Provider name> and access them from other devices and from <Provider website>.
+
+ If the user denies the transition of the known folders, the call will fail with `NSUserCancelledError`.
+
+ The call will fail if:
+ - one or more locations are not folders
+ - multiple locations are backed by the same folder
+ - a known folder doesn't live on the same volume as the root of the domain
+ - the known folders don't have the same parent folder
+ - ...
+
+ Currently, only claiming both ~/Desktop and ~/Documents together is allowed.
+ */
+- (void)claimKnownFolders:(NSFileProviderKnownFolderLocations *)knownFolders
+          localizedReason:(NSString *)localizedReason
+        completionHandler:(void (^)(NSError * _Nullable))completionHandler
+                            NS_SWIFT_NAME(claimKnownFolders(_:localizedReason:completionHandler:))
+                            FILEPROVIDER_API_AVAILABILITY_DESKTOP;
+
+/** Request that the system stops replicating the specified known folders in the domain.
+
+ This call can be used by the provider to immediately disable replication of the specified
+ known folders.
+ */
+- (void)releaseKnownFolders:(NSFileProviderKnownFolders)knownFolders
+            localizedReason:(NSString *)localizedReason
+          completionHandler:(void (^)(NSError * _Nullable))completionHandler
+                            NS_SWIFT_NAME(releaseKnownFolders(_:localizedReason:completionHandler:))
+                            FILEPROVIDER_API_AVAILABILITY_DESKTOP;
+@end
+
+#pragma mark - Responding to the system
+
+FILEPROVIDER_API_AVAILABILITY_DESKTOP
+@protocol NSFileProviderKnownFolderSupporting <NSObject>
+
+/** Request suitable locations for known folders.
+
+ This function is called when the user decides to switch some known folders to the current domain, outside of the `claimKnownFolders` call.
+ The system provides a list of folders that the user decides to move to this domain, and expect in return non-nil locations for those known
+ folders.
+ */
+- (void)getKnownFolderLocations:(NSFileProviderKnownFolders)knownFolders
+              completionHandler:(void (^)(NSFileProviderKnownFolderLocations * _Nullable, NSError * _Nullable))completionHandler;
+
+@end
+
+NS_ASSUME_NONNULL_END
diff -ruN /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderManager.h /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderManager.h
--- /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderManager.h	2024-04-14 19:27:47
+++ /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderManager.h	2024-05-30 10:45:21
@@ -572,4 +572,61 @@
                            completionHandler:(void (^)(NSError * _Nullable error))completionHandler NS_REFINED_FOR_SWIFT FILEPROVIDER_API_AVAILABILITY_V5_0;
 @end
 
+@interface NSFileProviderManager (StateDirectory)
+/**
+ A directory suitable for storing state information for the domain.
+
+ The returned URL is guaranteed to be on the same volume as the user visible URL and the temporary URL, making sure
+ the system can atomatically clone/move files from that location to the user visible URL.
+ The caller is responsible for managing the security scope of the returned URL.
+
+ When syncing a domain on an external volume, all information about the sync state must be kept in this directory
+ if the volume is to be shared between multiple machines.
+
+ If the system cannot find a suitable directory, this call will fail. This could happen e.g. if the domain
+ does not exist.
+
+ This call will not fail when called from the extension process with an active instance of the extension
+ for that domain.
+
+ Removing the domain will remove the corresponding directory along with it.
+*/
+- (nullable NSURL *)stateDirectoryURLWithError:(NSError *__autoreleasing  _Nullable *)error FILEPROVIDER_API_AVAILABILITY_EXTERNAL_VOLUME;
+@end
+
+typedef NS_OPTIONS(NSUInteger, NSFileProviderVolumeUnsupportedReason) {
+    NSFileProviderVolumeUnsupportedReasonNone           = 0,
+    NSFileProviderVolumeUnsupportedReasonUnknown        = 1 << 0,
+    NSFileProviderVolumeUnsupportedReasonNonAPFS        = 1 << 1,
+    NSFileProviderVolumeUnsupportedReasonNonEncrypted   = 1 << 2,
+    NSFileProviderVolumeUnsupportedReasonReadOnly       = 1 << 3,
+    NSFileProviderVolumeUnsupportedReasonNetwork        = 1 << 4,
+    NSFileProviderVolumeUnsupportedReasonQuarantined    = 1 << 5
+} FILEPROVIDER_API_AVAILABILITY_EXTERNAL_VOLUME;
+
+@interface NSFileProviderManager (ExternalDomain)
+
+/**
+ Check if a URL is eligible for storing a domain.
+
+ This returns whether the check has been performed succesfully - NOT whether the drive is eligible.
+
+ If an error was encountered while checking, this method returns FALSE and an error describing
+ the problem will be set.
+
+ The eligible parameter will contain the result of the check and indicate whether the volume can be
+ used to store FP domains. Its value is only defined if the call returns YES.
+
+ The url can be any existing and accessible URL on the volume for which you want to assess eligibility.
+ The checks are volume-wide and the exact location on the volume doesn't impact them.
+
+ If a drive is eligible, unsupportedReason will be empty (0). Otherwise it will contain the list of identified
+ conditions that currently prevent this drive from being used to store FP domains.
+ */
++ (BOOL)checkDomainsCanBeStored:(BOOL *)eligible
+                  onVolumeAtURL:(NSURL *)url
+              unsupportedReason:(NSFileProviderVolumeUnsupportedReason * _Nullable)unsupportedReason
+                          error:(NSError *_Nullable *_Nullable)error NS_REFINED_FOR_SWIFT FILEPROVIDER_API_AVAILABILITY_EXTERNAL_VOLUME;
+@end
+
 NS_ASSUME_NONNULL_END
diff -ruN /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderReplicatedExtension.h /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderReplicatedExtension.h
--- /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderReplicatedExtension.h	2024-04-14 19:27:47
+++ /Applications/Xcode_16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/FileProvider.framework/Headers/NSFileProviderReplicatedExtension.h	2024-05-30 05:02:42
@@ -1327,4 +1327,11 @@
 
 @end
 
+FILEPROVIDER_API_AVAILABILITY_EXTERNAL_VOLUME
+@protocol NSFileProviderExternalVolumeHandling <NSObject>
+
+- (void)shouldConnectExternalDomainWithCompletionHandler:(void (^)(NSError * _Nullable connectionError))completionHandler;
+
+@end
+
 NS_ASSUME_NONNULL_END
Clone this wiki locally