File Provider

RSS for tag

Allow other apps to access the documents and directories stored and managed by your containing app using File Provider.

Posts under File Provider tag

57 Posts

Post

Replies

Boosts

Views

Activity

How to tell if FileProvider Extension is enabled, programatically?
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 ?
1
0
131
May ’25
iOS 18.4 and getFileProviderServicesForItem
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?
5
2
320
Apr ’25
Detect if a file or folder is synced by cloud providers (Google Drive, iCloud, OneDrive, Dropbox, etc.) in iOS (all versions)
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 🙌
1
0
124
Apr ’25
Detection of file eviction
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?
2
0
127
Apr ’25
No valid file provider found with identifier
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
4
0
162
Apr ’25
File Provider Extension Conflict Resolution
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
1
0
156
Mar ’25
NSFileProviderPartialContentFetching on iOS
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.
1
0
144
Mar ’25
NSPOSIXErrorDomain code 12 while downloading a folder having sub directories and large number of files
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?
4
0
466
Mar ’25
File Provider Extension Rollback Action
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
1
0
341
Mar ’25
Can't refresh contents of File Provider -managed folder (Dropbox)
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.
5
0
570
Mar ’25
File Provider Extension Remote Server Change Apply Error
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?
1
0
486
Mar ’25
How to get ApplicationSupportDirectory from FileProvider extension?
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?
1
0
309
Feb ’25
macOS Sequoia: Shared UserDefaults don't work (the app-group is set as per macOS 15 Sequoia requirements)
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.
2
0
817
Feb ’25
[Bug] UIDocumentPickerViewController Crash: “DocumentManager service tried to send a message to a deallocated host proxy”
We are experiencing an issue where UIDocumentPickerViewController causes an uncaught exception when it is dismissed under certain conditions. The error appears as: <NSXPCConnection: 0x301ac7660> connection from pid 2075 on anonymousListener or serviceListener: Warning: Exception caught during invocation of selector _updateRemoteBarButtonFrames:forUUID:, dropping incoming message and invalidating the connection. Exception: DocumentManager service tried to send a message to a deallocated host proxy DocumentManager service tried to send a message to a deallocated host proxy ( 0 CoreFoundation 0x0000000186c2a608 0013A8B1-2524-3534-B5BA-681AAF18C798 + 185864 1 libobjc.A.dylib 0x00000001841a5244 objc_exception_throw + 88 2 Foundation 0x000000018602eec0 E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 8576704 3 DocumentManager 0x00000002177cf7b8 0BAEFA1B-BD6D-3472-A1B3-6E09F5DE54F2 + 96184 4 CoreFoundation 0x0000000186c2d078 0013A8B1-2524-3534-B5BA-681AAF18C798 + 196728 5 CoreFoundation 0x0000000186c2cef0 _CF_forwarding_prep_0 + 96 6 Foundation 0x00000001858b8d8c E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 753036 7 Foundation 0x00000001858b7fc8 E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 749512 8 Foundation 0x00000001858b7220 E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 746016 9 Foundation 0x00000001858b70d8 E2F95328-659E-3C01-97F7-52B5B3BB7AA5 + 745688 10 libxpc.dylib 0x00000002119f1a50 527F7127-9586-32C8-9D8B-2972D39EAD7A + 72272 11 libxpc.dylib 0x00000002119f35cc 527F7127-9586-32C8-9D8B-2972D39EAD7A + 79308 12 libdispatch.dylib 0x000000010160a638 _dispatch_client_callout4 + 20 13 libdispatch.dylib 0x0000000101627eac _dispatch_mach_msg_invoke + 512 14 libdispatch.dylib 0x000000010161226c _dispatch_lane_serial_drain + 352 15 libdispatch.dylib 0x0000000101628ea4 _dispatch_mach_invoke + 492 16 libdispatch.dylib 0x000000010161226c _dispatch_lane_serial_drain + 352 17 libdispatch.dylib 0x0000000101613290 _dispatch_lane_invoke + 460 18 libdispatch.dylib 0x00000001016206fc _dispatch_root_queue_drain_deferred_wlh + 328 19 libdispatch.dylib 0x000000010161fd0c _dispatch_workloop_worker_thread + 580 20 libsystem_pthread.dylib 0x0000000211998680 _pthread_wqthread + 288 21 libsystem_pthread.dylib 0x0000000211996474 start_wqthread + 8 ) *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'DocumentManager service tried to send a message to a deallocated host proxy' Steps to Reproduce Present a UIDocumentPickerViewController inside a custom UIViewController. Dismiss the parent UIViewController before UIDocumentPickerViewController is fully visible. Swipe down or press the “Cancel” button in the picker. Occasionally, the system forcefully terminates the view service, causing a crash. Workarounds Tried (Unsuccessful) Using UIAdaptivePresentationControllerDelegate – Not Called for UIDocumentPickerViewController. Using viewDidDisappear to clean up – Not Called when the system terminates the picker. Forcing dismissal before presenting a new picker Reference to Line 42 in DOCRemoteViewController.m From the error traceback, we see a reference to DOCRemoteViewController.m line 42, which strongly suggests that UIDocumentPickerViewController relies on a background process to manage its lifecycle. Since we don’t have access to Apple’s private code, we assume that the DocumentManager service is trying to send a message to an already deallocated instance of UIDocumentPickerViewController, leading to a crash. One of the example wrapper implementation of us: class DocumentPickerViewController: UIViewController, UIDocumentPickerDelegate { private var picker: UIDocumentPickerViewController? weak var delegate: UIDocumentPickerDelegate? override func viewDidLoad() { super.viewDidLoad() print("📄 DocumentPickerViewController - viewDidLoad() called") setupDocumentPicker() } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) print("📄 DocumentPickerViewController - viewDidAppear() called") } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) print("📄 DocumentPickerViewController - viewWillAppear() called") } override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) print("📄 DocumentPickerViewController - viewWillDisappear() called") } override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) print("📄 DocumentPickerViewController - viewDidDisappear() called") } deinit { print("🗑 DocumentPickerViewController - deinit() called") } // MARK: - Setup Document Picker private func setupDocumentPicker() { picker = UIDocumentPickerViewController(forOpeningContentTypes: [.pdf]) picker?.delegate = self picker?.allowsMultipleSelection = false picker?.modalPresentationStyle = .formSheet if let picker = picker { present(picker, animated: false) { print("📄 Document Picker fully presented") } } } // MARK: - UIDocumentPickerDelegate Methods func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { print("✅ User selected document(s): \(urls)") delegate?.documentPicker?(controller, didPickDocumentsAt: urls) dismissSelf() } func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) { print("❌ User cancelled document selection") delegate?.documentPickerWasCancelled?(controller) dismissSelf() } private func dismissSelf() { DispatchQueue.main.async { [weak self] in self?.dismiss(animated: true) } } } And logs for this implementation: 📄 Document Picker fully presented 📄 DocumentPickerViewController - viewDidAppear() called ❌ User cancelled document selection The view service did terminate with error: Error Domain=_UIViewServiceErrorDomain Code=1 "(null)" UserInfo={Terminated=disconnect method} 📄 DocumentPickerViewController - viewDidLoad() called 📄 Document Picker fully presented 📄 DocumentPickerViewController - viewDidAppear() called would appreciate any workarounds from the community to prevent crashes related to this issue!
4
1
762
Feb ’25
File Provider Extension trouble
Hi everyone, I am a beginner in iOS/Swift programming. I'm trying to develop a mobile application that allows to mount a network drive in the iphone Files application via the WebDav protocol. I saw on the internet that WebDav is no longer implemented in iOS because considered deprecated by apple. To accomplish this task, I decided to separate responsibilities as follows: Framework: WebDav (responsible for communication with the WebDav server) FileProviderExtension: FileBridge (Responsible for bridging the gap between the WebDav Framework and the iOS Files app) Main App I also have an AppGroup that includes the main application and the fileproviderextension Initially, to measure the feasibility and complexity of this task, I'd like to make a simplistic version that simply displays the files on my drive in the Files app, without necessarily being able to interact with them. FileProviderExtension.swift: import FileProvider import WebDav class FileProviderExtension: NSObject, NSFileProviderReplicatedExtension { private var webDavService: WebDavService? required init(domain: NSFileProviderDomain) { super.init() self.webDavService = WebDavService(baseURL: URL(string: "https://www.mydrive.com/drive")!) } func invalidate() { // TODO: cleanup any resources } func item(for identifier: NSFileProviderItemIdentifier, request: NSFileProviderRequest, completionHandler: @escaping (NSFileProviderItem?, Error?) -> Void) -> Progress { let progress = Progress(totalUnitCount: 1) Task { do { if let items = try await webDavService?.propfind(path: identifier.rawValue, depth: 1), let item = items.first(where: { $0.itemIdentifier == identifier }) { completionHandler(item, nil) } else { completionHandler(nil, NSError(domain: NSCocoaErrorDomain, code: NSFileNoSuchFileError, userInfo: nil)) } } catch { completionHandler(nil, error) } } return progress } func fetchContents(for itemIdentifier: NSFileProviderItemIdentifier, version requestedVersion: NSFileProviderItemVersion?, request: NSFileProviderRequest, completionHandler: @escaping (URL?, NSFileProviderItem?, Error?) -> Void) -> Progress { let progress = Progress(totalUnitCount: 1) Task { do { guard let service = webDavService else { throw WebDavError.invalidResponse } let data = try await service.get(fileAt: itemIdentifier.rawValue) let tempURL = FileManager.default.temporaryDirectory.appendingPathComponent(itemIdentifier.rawValue) try data.write(to: tempURL) completionHandler(tempURL, nil, nil) } catch { completionHandler(nil, nil, error) } } return progress } func createItem(basedOn itemTemplate: NSFileProviderItem, fields: NSFileProviderItemFields, contents url: URL?, options: NSFileProviderCreateItemOptions = [], request: NSFileProviderRequest, completionHandler: @escaping (NSFileProviderItem?, NSFileProviderItemFields, Bool, Error?) -> Void) -> Progress { // TODO: a new item was created on disk, process the item's creation completionHandler(itemTemplate, [], false, nil) return Progress() } func modifyItem(_ item: NSFileProviderItem, baseVersion version: NSFileProviderItemVersion, changedFields: NSFileProviderItemFields, contents newContents: URL?, options: NSFileProviderModifyItemOptions = [], request: NSFileProviderRequest, completionHandler: @escaping (NSFileProviderItem?, NSFileProviderItemFields, Bool, Error?) -> Void) -> Progress { // TODO: an item was modified on disk, process the item's modification completionHandler(nil, [], false, NSError(domain: NSCocoaErrorDomain, code: NSFeatureUnsupportedError, userInfo:[:])) return Progress() } func deleteItem(identifier: NSFileProviderItemIdentifier, baseVersion version: NSFileProviderItemVersion, options: NSFileProviderDeleteItemOptions = [], request: NSFileProviderRequest, completionHandler: @escaping (Error?) -> Void) -> Progress { // TODO: an item was deleted on disk, process the item's deletion completionHandler(NSError(domain: NSCocoaErrorDomain, code: NSFeatureUnsupportedError, userInfo:[:])) return Progress() } func enumerator(for containerItemIdentifier: NSFileProviderItemIdentifier, request: NSFileProviderRequest) throws -> NSFileProviderEnumerator { return FileProviderEnumerator(enumeratedItemIdentifier: containerItemIdentifier, service: webDavService) } } Here's the code I use to initialize my domain in the main app files: fileprivate func registerFileProviderDomain() { let domainIdentifier = NSFileProviderDomainIdentifier("FileProviderExtension Bundle Identifier") let domain = NSFileProviderDomain(identifier: domainIdentifier, displayName: "My Drive") NSFileProviderManager.add(domain) { error in NSFileProviderManager.add(domain) { error in if let error = error { print("Error cannot add domain file provider : \(error.localizedDescription)") } else { print("Success domain file provider added") } } } I can't get rid of the Error : Error cannot add domain file provider : The operation couldn’t be completed. Invalid argument. I don't know what I'm missing Please help me understand
1
1
1k
Jan ’25
DocumentGroup Fails to Display Document Content in Mac Catalyst App
When running a Mac Catalyst app that uses DocumentGroup, the app fails to display the document content. The document picker works as expected, but creating a new document or opening an existing one results in an empty window. This issue occurs regardless of whether “Optimize for Mac” or “Scale iPad” is selected. Steps to Reproduce: 1. Download the sample project provided by Apple for building a document-based app in SwiftUI. 2. Delete the macOS version of the project. 3. Add a Mac Catalyst version of the app. 4. In the Mac Catalyst settings, select “Optimize for Mac” (the bug also appears if it is “Scale iPad”). 5. Run the project on macOS. Expected Result: The app should correctly display the content of the document when creating or opening it. Actual Result: The app opens an empty window when a new document is created or an existing one is opened. Impact: We have received multiple 1-star reviews, and our retention has dropped by two-thirds due to this issue. Environment: Xcode 16.1; macOS 15.1 & 15.2 (on 15.0 it works fine) Has anyone experienced the same issue? I filed multiple reports so far.
3
1
956
Dec ’24