General:
DevForums tags: Files and Storage, Finder Sync, File Provider, Disk Arbitration, APFS
File System Programming Guide
On File System Permissions DevForums post
File Provider framework
Finder Sync framework
App Extension Programming Guide > App Extension Types > Finder Sync
Disk Arbitration Programming Guide
Mass Storage Device Driver Programming Guide
Device File Access Guide for Storage Devices
Apple File System Guide
TN1150 HFS Plus Volume Format
Extended Attributes and Zip Archives
File system changes introduced in iOS 17 DevForums post
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
File Provider
RSS for tagAllow other apps to access the documents and directories stored and managed by your containing app using File Provider.
Posts under File Provider tag
62 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
We have a seemingly randomly (and rarely) reproducible bug when a Microsoft Word (or Excel, Powerpoint...) temporary file with the ~$ prefix is not removed when the document is closed and causes a remotely deleted folder to be recreated via our file provider extension. We have received multiple issues from our users for some time now, and we could not reproduce it so far, but finally got a repro but could not identify the cause.
We could reproduce it with the following steps, however not always, and only on one computer:
We have the following file: FileProviderRoot/TEST/INSIDE/somefile.docx
Open this file, edit with MS Word. A ~$mefile.docx hidden, temporary file is created next to the original file, while it is open in Word. This temp file is ignored by our file provider implementation by returning an .excludeFromSync error code.
Save the file, modifications are synced. (don't know if this step is needed)
We delete the container folder (FileProviderRoot/TEST/INSIDE) from within our app, the deletion change is propagated to the file provider, which in turn receives a call to createItem(basedOn:fields:contents:options:request:completionHandler:) that recreates the INSIDE folder, as - for some reason - the temp file cannot be deleted. Now we are stuck in this loop of delete/recreate until we go into the file provider folder and manually remove the stuck temp file.
We would expect that the folder is not recreated but also removed from the file provider and disk along with the temp file.
On the device that this issue was reproduced, it also seems to work correctly most of the time, but needs manual fixing when this issue occurs.
We have a related bugreport: FB17928069
I am developing a FileProvider on Mac OS. I want to support Coauthoring Via Microsoft. As per Microsoft's documentation, the supportedServices function should be called via the OS when an Office file is opened. I have overridden this function in my fileprovider extension, but fail to see this function getting called.
Has anyone else had any experience with coauthoring integration for File Provider and could give some advice?
I am mostly working from the given documentation from Microsoft https://learn.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/plus/sync-client/metadata
Hi
We have a non-replicated Files Provider extension on iOS that creates multiple domains. I've noticed that iOS typically creates one process per domain, so I would assume that each process is meant to handle one domain. However, in practice, is seems that calls for any domain can occur in any process.
I'm wondering whether there is supposed to be a mapping, implying there might be something wrong with the code, or whether we shouldn't make assumptions about domain:process mapping.
Thanks for any info you can provide.
In the FileProvider framework, most of the functions (such as fetchPartialContentsForItemWithIdentifier, fetchContentsForItemWithIdentifier etc.) are expected to return an NSProgress object. In a case where an error is encountered before the function returns the NSProgress object, is it allowed to invoke the completionHandler with an error prior to returning the NSProgress object to the File Provider framework?
I'm not sure if I have found a bug with iOS or if it's just unexpected behavior with my implementation. I have a gomobile library that sets up a local http server. It needs to be able to write to temporary storage. If I use the shared library from my main apps process it can write to the file manager.default temporary storage.
while Xcode is running a debug session I can use that same process from my file provider replicated extension and it works fine. However I realized running my file provider extension where it starts the gomobile shared library directly instead of first from my app the library fails to write anything to the file provider manager default temporary storage or the file provider manager for my file provider domain temporary storage or even the app group library.
it is odd, because I have a swift URL extension that confirms the temporary storage can be written to from swift. I have monitored console logs for fileproviderd, my file extension and have tried writing data to a log file. nothing seems to catch exactly what causes the file provider extension to crash and restart.
I also cannot keep the shared gomobile server running in the background on iOS even if I were to force the user to "authenticate" with the main app first. Im pretty sure the file provider extension needs to run the gomobile library for it to work right.
I'm wondering if something may be wrong with the iOS sandbox that could be preventing the file provider extension to let a c based gomobile shared library from accessing the temporary storage.
Any guidance for further things to try would be greatly appreciated. I have tried every avenue I can think of.
I cannot run just the appex itself on either my m4 pro MacBook or my iPhone so attaching the debugger has been tricky and I don't see much in the way of useful logs in console app either just a swarm of noise.
Im fairly confident it's an issue to writing to temporary storage from the gomobile c library and not much else. App was working great on macOS designed for iPad which just seemed rather ironic that an iOS code base runs better on macOS than it was able to on my iPhone 16 pro max. Like im all for the sandbox I just wish it didn't treat c level gomobile libraries different than it treats the swift code itself.
We are experimenting with FileProvider on MacOS, we want to set ACL policy restriction on a folder and the same policy needs to be applied down to its children. To achieve this currently we are setting corresponding NSFileProviderItemCapabilities on parent folder and recursively iterate over all of its children and set the capability on each individual child items.
GOAL: We expect the root's ACL policy to be implicitly percolated down to its children without explicitly being iterated over them and setting it individually.
From our research, we couldn't find any policy that can help us achieve the above goal. If there are any such provisions in FileProvider, please guide us to them.
I tried using Pluginkit via terminal to determine if a File Provider Extension is enabled on Mac OS.
Although I see the extension listed in the output of pluginkit -m, The status of + or - doesn't seem to change in this output when I disable or enable the FileProvider extension in System Settings.
Is there a more reliable way to determine if the extension is enabled ?
Hi all,
I’m building an iOS app where I need to determine user picked files or folders using UIDocumentPickerViewController, whether the selected item is synced or managed by a cloud storage provider such as:
Google Drive
iCloud Drive
OneDrive
Dropbox
or any third-party File Provider extension
My intent is to detect this and optionally warn the user that the item may be subject to syncing behavior.
So far, I’ve tried a few different approaches:
Extended Attributes (listxattr / getxattr) While this does not give reliable outcome.
Heuristically search for keywords like 'Drive', 'GoogleDrive' etc But this is also not reliable.
Question
Is there any possible reliable and documented way to detect programmatically if a file/folder is cloud-synced or managed by a File Provider from within a regular iOS app (not an extension), especially for:
Google Drive
OneDrive
Dropbox
iCloud
Other third-party providers?
Also, is there any recommended fallback strategy for iOS versions prior to 17 where NSFileProviderManager may have limitations?
Any input from Apple engineers or those who have tackled this would be hugely appreciated!
Thanks in advance 🙌
Topic:
App & System Services
SubTopic:
Core OS
Tags:
Files and Storage
iOS
File Provider
iCloud Drive
Hi
Is there a way to check if a file at a specified URL is open and being edited by another application. Assuming that we have permission to access the file at the URL.
I want to implement quota feature to my file provider extension. I am able to keep track of materialized files total size. (Content download and edit operations)
However I cannot detect file eviction operation (User right click to file and select "Remove Download"). Is there anyway to detect this action
Or any suggestion to keep track of materialized files total size?
I support a pair of iOS apps that use a file provider extension. One app exposes a file provider extension, including a file provider extension service and the other app interacts with the file provider extension and uses the service.
On iOS 18.3 and before, this all works fine.
On iOS 18.4, getFileProviderServicesForItem fails when called from the consuming app with: Error Domain=NSCocoaErrorDomain Code=513 "The file couldn’t be saved because you don’t have permission." The supportedServiceSources method in the service hosted by the provider app is never invoked when this occurs. Is there some change to the mechanism for iOS 18.4 that I've not found yet?
I was able to add new domain with 'NSFileProviderManager.add' function in Xcode past 2 months. Yesterday I created .pkg file (installer file) for distribution with 'pkgbuild' and 'productbuild' commands in terminal.
I successfully install application and test it then uninstall it. However after this, In Xcode I cannot add new domain anymore. I keep getting "Error Domain=NSFileProviderErrorDomain Code=-2001 "No valid file provider found with identifier ‘’."
Command that used to create .pkg file
pkgbuild --root "path" --scripts "path" --identifier "same bundle identifier with app" --version 1.0 --install-location /Applications "newpkg.pkg"
productbuild --synthesize --package "newpkg.pkg" Distribution.xml
productbuild --distribution Distribution.xml --package-path "newpath.pkg" "newpathrelease.pkg"
NOTE: When app is installed (But not running). I am able to add new domain in Xcode. After I uninstall app, I start to get same error again
NOTE: I uninstall app by move it to Trash from Applications directory in finder
Any suggestion about add new domain in Xcode during development? Or How to fix 'No valid file provider found with identifier' error
Hi all, i am trying to implement File Provider Extension. I have some questions about conflict resolution
Same file is changed at user local and remote storage before it's synced. File has 2 different version at user local and remote storage. After trigger a new enumeration by calling signalEnumerator for the extension, I want to move user's local version to new conflicted copy (with new itemIdentifier: NSFileProviderItemIdentifier) and import remote storage version to user local (with current itemIdentifier: NSFileProviderItemIdentifier). Then users local version should uploaded to remote storage server with new conflicted copy name
Any suggestion about this scenario? Or any documentation about conflict resolution
We're experimenting with FileProvider on MacOS and iOS. One of our requirements is to support downloading partial content of files. However, this looks to be supported only on MacOS as per https://developer.apple.com/documentation/fileprovider/nsfileproviderpartialcontentfetching?language=objc.
Is there an alternative for NSFileProviderPartialContentFetching on iOS? If not, can you please share any standard practice on how to accomplish this on iOS?
Sample code that works on MacOS -
#import <FileProvider/FileProvider.h>
@interface FileProviderExtension : NSObject<NSFileProviderReplicatedExtension, NSFileProviderPartialContentFetching>
For iOS platform, NSFileProviderPartialContentFetching isn't available and build fails.
Hi,
I have a file provider based MacOS application where i have a drive added and am trying to download a folder from that drive.
The folder has sub folders and large files in it.
After some time of download started, i keep getting below error.
error: ["The operation could not be completed. Cannot allocate memory", [code: 12, domain: "NSPOSIXErrorDomain"]
The download action is triggered via Finder's download icon(cloud icon with down arrow).
I am using native URLSession to download the files from server. No third party library is used.
What could be the possible reasons for "can not allocate memory" issue?
Hi all, i am trying to implement File Provider Extension. I have some scenarios that I can not figure out,
User delete a file on local. 'deleteItem' callback is triggered. I send delete request to remote server. Remove server failed to apply deletion (for some reason deletion failed, blocked). I call 'completionHandler' with necessary error but here is the problem. File is removed in user local but exit in remote server. After some time 'deleteItem' callback is triggered multiple times for this file. I need to put same file in user local (rollback deletion) and stop triggered callbacks.
I have a folder named "New folder". This folder is dataless (its sub items is not enumerated yet). User add a file named "a.txt" to this folder on remote server. I detect that addition. When I apply that addition with 'NSFileProviderChangeObserver' observers 'didUpdate' method then enumerate this directory "a.txt" is duplicated (a 2.txt is created). Is there any way to control folder named "New folder" is dataless (its sub items is not enumerated) so that I can skip file addition to prevent duplication.
Any suggestion about above scenarios
Hi all, i am trying to implement File Provider Extension. I was able to enumerate remote storage directories to local via 'enumerateItems' function of NSFileProviderEnumerator.
I can apply remote storage changes like newly created files/folders, move, rename and delete operations and successfully apply them to local with 'NSFileProviderChangeObserver' class 'didUpdate' and 'didDeleteItems' functions.
However when file content is updated on remote server;
If file content is not fetched(file is Dataless), i can not apply this change to local. When i call 'NSFileProviderChangeObserver' class 'didUpdate' function for changed file, only DateModified attribute is updated on finder, file size is not changed to new size.
If file content has been fetched, When i call 'NSFileProviderChangeObserver' class 'didUpdate' function nothing is changed, file content stay depreciated
Any suggestion how to fix it?
I want a user to be able to save a URL of a folder on a cloud share using the standard FileManager APIs. I'm testing with Dropbox in particular. The initial interaction is working (I can select a folder, save it as a bookmark, and scan the files in that folder). However, no changes made externally to the folder will be reflected in the app when I refresh the contents.
Launching the Files app and browsing to the folder DOES show the updated contents, and once that step is complete, then my app will again show up-to-date contents.
Is there perhaps some API I should be calling to trigger the Dropbox File Provider extension to update it's cache?
Sample project demonstrating issue: https://github.com/dhennessy/FolderScan
STEPS TO REPRODUCE
Launch the app on a physical device
Tap Choose, browse to folder on a Dropbox share, tap Open to select
The app will show the contents of the folder (the 'test' folder)
Switch to the Dropbox app and create a new subfolder of the test folder
Return to the test app and tap Refresh. Notice that the changes do not appear
Re-launching the app also does not show the changes
Workaround
Launch the Files app (or re-open the UIDocumentPickerViewController by tapping choose and then dismiss it)
Tap Refresh and the changes will appear in the app
Note: None of the other 'cloud file providers' (google drive, one drive, box) even allow the user to even select a folder.
I get the ApplicationSupportDirectory path like this:
let path = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true)[0] as String
however for FileProvider plugin it looks like:
/var/mobile/Containers/Data/PluginKitPlugin/.../Library/Application Support/rclone.conf
instead of what I get for an Application:
/var/mobile/Containers/Data/Application/.../Library/Application Support
I need a way to get the Application's Support Directory from the FileProvider plugin.
Is that possible? If not, what other shared location I could use to access shared file between these two?
I use shared UserDefaults in my Swift FileProvider extension app suite. I share data between the containing app and the extension via User Defaults initialized with init(suiteName:).
Everything was working fine before macOS 15 (Sequoia).
I know that Sequoia changed the way the app group should be configured. My app group is know set to "$(TeamIdentifierPrefix)com.my-company.my-app".
But the containing (UI) app and the Extension read and write from and to different plist locations although the same app-group is specified for both targets in XCode.
The containing app reads and writes to "~/Library/Preferences/$(TeamIdentifierPrefix)com.my-company.my-app.plist"
The Extension reads and writes to "~/Library/Containers/com.my-company.my-app.provider/Data/Library/Preferences$(TeamIdentifierPrefix)com.my-company.my-app.plist"
Both of these locations seem completely illogical for shared UserDefaults.
I checked the value returned by FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "$(TeamIdentifierPrefix)com.my-company.my-app" in both the containing app and the Extension and the value in both of them is the same but has nothing to do with the actual paths where the data is stored as provided above. (The value is as expected - "~/Library/Group Containers/$(TeamIdentifierPrefix)com.my-company.my-app/"
P.S. Of course, $(TeamIdentifierPrefix), my-company and my-app here are placeholders for my actual values.