File Provider

RSS for tag

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

File Provider Documentation

Pinned Posts

Posts under File Provider tag

83 Posts
Sort by:
Post not yet marked as solved
0 Replies
333 Views
Hello folks, While the API for FileProviderUI is listed as supporting VisionOS 1.0, Xcode Cloud complains at the first step of the build with: "Unsupported Platform. The extension bundle LaTerminal.app/PlugIns/LaTerminalFileProviderUI.appex is not supported for this platform. Please refer to the App Extension Programming Guide at http://developer.apple.com." I also noticed that while you can create a FileExtension from Xcode, there is no template for creating the FileExtensionUI on Xcode for VisionOS projects. Could use some guidance as to what I could be doing wrong.
Posted
by
Post not yet marked as solved
0 Replies
289 Views
Hello all, When copying a lot of files using NSFileProviderReplicatedExtension (more than 2000 files) to the a local storage, fetchContents is called for each file, but usually after around 2000 files, fetchContents is not called anymore. No errors, no invalidate() called, no cancelations, no log messages, just silence. Is there any explanation or solution for this behaviour? I want the extension to provide all files until the end. By the way, if the transfer fails, but you double click on the local folder a "Finish Copying" option is presented and after that fetchContents for the remaining files is called (which is good). Thank you.
Posted
by
Post not yet marked as solved
6 Replies
604 Views
Hello, Anyone know of relevant documentation that captures the difference between vfsStruct.f_fsid and fstat.st_ino ? sys/stat.h declares: ino_t st_ino; /* [XSI] File serial number */ AND sys/statvfs.h declares: unsigned long f_fsid; /* Filesystem ID */ Based on some tests, it seems that the st_ino is the number/inode_number that the filesystem identifies the file-resource by ? I observed that this number gets a unique value when I copy a file even when the Finder/FS utilizes the Space-Saver feature of MacOS. This value is identical to the results returned by the command ls "-i" . When copying via Finder, I am seeing distinct st_ino values for source and destination files. f_fsid seems to be identifying the File differently though, perhaps taking into account what Data/attributes objects the file resource points to ? I observed that this number gets an identical value when I copy a file even when the Finder/FS utilizes the Space-Saver feature of MacOS. So, the value of f_fsid seems to be copied over to the destination file record. Also, I could not find a way to display f_fsid via the ls command. On a related note, Any documentation regarding MacOS Finder/FS's Space-Saver feature or how it is implemented ? Thanks, Vikram.S.Warraich
Posted
by
Post not yet marked as solved
0 Replies
330 Views
I am trying to populate the Finder comment field from extendedAttributes with the code bellow but it doesn't work. Any idea why ? var extendedAttributes: [String : Data] { var attrs = [String: Data]() let comment = self.caption do { let xmlPlistData = try PropertyListSerialization.data(fromPropertyList: comment as Any, format: .xml, options: 0) attrs["com.apple.metadata:kMDItemFinderComment"] = xmlPlistData } catch { NSLog("Error during plist conversion: \(error)") } return attrs }
Posted
by
Post not yet marked as solved
1 Replies
401 Views
Hello, I have another quick question. I'm using NSFileProviderReplicatedExtension to create a macOS File Provider app to access remote files directly in Finder. When I copy a file to a remote folder (managed by File Provider) "createItem(basedOn itemTemplate: NSFileProviderItem, fields: NSFileProviderItemFields ....)" is triggered and this is fine. But immediately after the file is upload fetchContents(for itemIdentifier: NSFileProviderItemIdentifier, version ...)" is also triggered. Is this expected? Downloading again the file after upload requires some time and it's not the best experience for the user if he is in a hurry. Is there any way to prevent this? Thank you.
Posted
by
Post not yet marked as solved
2 Replies
415 Views
Hello, I'm having some problems in implementing a File Provider based app. NSFileProviderEnumerator is very slow for many files (over 2000 files). I'm using pagination like this: observer.didEnumerate(paged_files) // page size is usually 200 let nextPage = NSFileProviderPage((page + 1).description.data(using: .utf8)!) observer.finishEnumerating(upTo: nextPage) and observer.finishEnumerating(upTo: nil) when finished all pages. But after calling "observer.finishEnumerating(upTo: nil)" it still takes a lot of time (20-30 seconds) until all files are listed in Finder. Any tips? Thank you.
Posted
by
Post not yet marked as solved
0 Replies
349 Views
Hello, I have a quick question. In my File Provider based Mac application, if the user copies a folder to his computer, the "download" progress indicator near the folder name (the one from Finder) is showing only if the user entered the folder before. If the user did not enter the folder before and copies the folder, the progress indicator is showing always zero and jumps to 100% after the copy operation is over. Any thought on this? Thank you.
Posted
by
Post marked as solved
1 Replies
321 Views
tl;dr I'm trying to get the FruitBasket demo to operate (Synchronizing files using file provider extensions | Apple Developer Documentation) on Sonoma 14.1.2. I'm probably being stupid about something but It doesn't work as I expect so would welcome any suggestions. Details I downloaded the FruitBasket demo code I attempted to carefully follow the README and replace all instances of group.com.example.apple-samplecode.FruitBasket I built and ran and created a domain My new domain appears in the Finder side-bar. It appears as a directory in ~Library/CloudStorage/. But attempting to (e.g.) ls ~/Library/CloudStorage/* gives me an ETIMEDOUT error and the Finder says something similar. Things that I observed: once a domain exists, there is indeed a Provider executable running. it never generates any log messages attaching the Xcode debugger to it and setting some seemingly likely to be invoked breakpoints (e.g. Extension.Extension.enumerator) never hit the breakpoints. my naïve take on the disassembly when pausing it suggests that it's waiting for incoming Mach messages. (That seemed sensible.) FruitBasket starts with an error: Couldn't read values in CFPrefsPlistSource<0x6000039853b0> (Domain group.org.liqui.apple-samplecode.FruitBasket, User: kCFPreferencesAnyUser, ByHost: Yes, Container: (null), Contents Need Refresh: Yes): Using kCFPreferencesAnyUser with a container is only allowed for System Containers, detaching from cfprefsd Questions Does the above error suggest that I have set the group value wrong somewhere? Maybe Extension+Servicing.swift:21 defining the NSFileProviderServiceName("com.example.FruitService") is mismatched somewhere?
Posted
by
Post not yet marked as solved
6 Replies
560 Views
Hello, I was testing with forms in applications in xcode, I created a button to import a file and a simple label where the name of the file was displayed. This tested in a simulator works perfectly, but when I send it to TestFlight and download it to my iPad, it opens the documentPicker but when I choose a file it does not load anything. No errors shown, no permissions issues. What could it be?
Posted
by
Post marked as solved
1 Replies
606 Views
Has anyone else been unable to trigger item eviction? Note I am using MacOS Sonoma 14.1 on a Macbook Air M1. I have attempted using both the swift API myFileProviderManager.evictItem(myItemID) as well as the CLI tool fileproviderctl evict "path/to/myFile.txt" and both return Error Domain=NSFileProviderErrorDomain Code=-2008 "The file ‘myFile.txt’ cannot be evicted.". This error maps to the nonEvictable error. Therefore I attempted providing the necessary permissions to evict my file. I have attempted applying all 4 possible configurations of NSFileProviderContentPolicy to this file. I have tried the legacy option of using the capability .allowsEviction. I have even tried with NSExtensionFileProviderAllowsUserControlledEviction set to both YES and NO as I noticed Dropbox was able to evict items even though this option was set to NO. None of these attempts have succeeded. I noticed if I ran fileproviderctl evict "path/to/myFile.txt" --namespace I was able to see that the file has the contentPolicy of 1 which maps to the downloadLazily contentPolicy. The NSFileProviderContentPolicy code documentation states that with this configuration will "Allow eviction on low disk pressure and other triggers." For clarity here is a table of my various attempts with NSExtensionFileProviderAllowsUserControlledEviction set to YES: NSFileProviderContentPolicy With Evict Capability Without Evict Capability None (i.e. default) 2008 Failed to evict 2008 Failed to evict inherited 2008 Failed to evict 2008 Failed to evict downloadLazily 2008 Failed to evict 2008 Failed to evict downloadEagerlyAndKeepDownloaded 2008 Failed to evict 2008 Failed to evict downloadLazilyAndEvictOnRemoteUpdate 2008 Failed to evict 2008 Failed to evict What am I missing? Is the documentation outdated? Is this a bug? Any tips will be greatly appreciated!
Posted
by
Post not yet marked as solved
3 Replies
624 Views
I am developing a cloud-based application and have integrated the FileProviderExtension. However, files larger than 20 MB are not downloading as it’s throwing a memory limit exception. In this process, I have downloaded the file data, but after downloading the data, I need to decrypt the data. I am getting a memory limit exception during decryption. I am using the below lines to decrypt the data. let symmetricKey = SymmetricKey(data: key) let sealedBox = try AES.GCM.SealedBox(combined: inputData) let decryptedData = try AES.GCM.open(sealedBox, using: symmetricKey) I am getting memory limit exception at AES.GCM.open(sealedBox, using: symmetricKey)
Posted
by
Post not yet marked as solved
2 Replies
449 Views
I was successfully able to get the callback for file reads for the files in my mounted folder. Now we need to implement some read protection on top of that, we need to only allow some specific applications to access the data through the File provider. for that, we need to get the name or any information regarding the Application that requested the read. one thing I've seen is the request.requestingExecutable , which is coming nil for all the applications trying to read the files in the mounted folder. But i do get applications name for the things done by finder (drag&drop and Copy paste) . What are the ways I can get the reading Application names ? and what could be done for implementing data leak features working in pair with the File Provider Extension ?
Posted
by
Post not yet marked as solved
1 Replies
519 Views
I am developing a cloud-based application and have integrated the FileProviderExtension. However, files larger than 20 MB are not downloading as it’s throwing a memory limit exception. In this process I have downloaded the file data but after downloaded data need to decompression the data . I am getting memory limit exception during decompression. I am using below file to decompress the data. let decompressedData = try? decryptedChunkBytes?.gunzipped() Data+Gzip.swift
Posted
by
Post not yet marked as solved
0 Replies
266 Views
I'm working on a Replicated File Provider extension for macOS. I've come across an issue recently on macOS 13+. It seems that the displayName of the domain changes when I call addDomain multiple times with the same NSFileProviderDomainIdentifier but with different displayName parameters. This behavior seems correct so far. However, the displayName, and of course the actual path under CloudStorage, revert back to their original values when I call disconnect to a domain manager. Here's the code snippet of getting existing doamin and disconnecting it: NSFileProviderManager.getDomainsWithCompletionHandler() { domainList, error in defer { dispatchGroup.leave() } for domain in domainList { if domain.identifier == NSFileProviderDomainIdentifier(rawValue: String(sessionId)){ domainResult = domain break } } } dispatchGroup.wait() guard let manager = NSFileProviderManager(for: domainResult) else { return -1 } manager.disconnect(reason: disconnectReason, options: []) { error in defer { dispatchGroup.leave() } errorResult = error } dispatchGroup.wait() Could a member of the internal team please help confirm if this is the correct method for updating the displayName of an existing domain? Additionally, is there a way to ensure that the new displayName persists even after disconnecting it? It would be great to allow users to customize and set a meaningful name for it. Thanks. Min
Posted
by
Post not yet marked as solved
0 Replies
440 Views
Hello, I want to fetch all local music files from an iPhone device. I tried MPMediaQuery but I can get only that file which is in the document folder.If we use UIDocumentpicker we can fetch all files from the iPhone (downloads, File Application)after selection by the user. I want to fetch all music files like UIDocumentpicker but without user interaction. Thanks in Advance for your guidance.
Posted
by
Post not yet marked as solved
2 Replies
1.3k Views
My computer crashed recently, and afterwards a lot of my files wouldn't open and it said it was because of "nsfileprovidererrordomain error -2005." I tried looking up what to do but nothing online really made sense and it was not offering me a solution to the problem. What should I do?
Posted
by
Post not yet marked as solved
2 Replies
718 Views
Hello, We have an iOS app which stores PDF files locally and allows them to be opened in place for editing by third-party apps (e.g. PDF Viewer / Xodo). We have found that the technique we were using to do this is not working as expected in iOS 17, where it does in all previous iOS versions. As per the File Provider documentation,: we are storing files locally, so presume we do not need to have a File Provider extension we set to true/YES both UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace we generate an NSUrl and, via UIDocumentInteractionController presentOpenInMenu, allow the user to open the PDF in an external app On iOS 16 and lower, it works as expected; the third-party app is able to read and automatically save changes to the PDF directly in our app's folder path. For example, the Xodo logs indicate that it's opening directly from our app's path (788C7161-32EB-4AF0-964D-2A473257A791 is our application's ID): Xodo initialized document instance: <PTCoordinatedDocument: 0x282453a00> fileURL: file:///private/var/mobile/Containers/Data/Application/788C7161-32EB-4AF0-964D-2A473257A791/Documents/7cafe7e7-9da9-40cd-b233-a85b0174fe00/624cbc1e-a7c5-4c0d-8937-b0a00013b2a9.pdf Xodo opening document: <PTCoordinatedDocument: 0x282453a00> fileURL: file:///private/var/mobile/Containers/Data/Application/788C7161-32EB-4AF0-964D-2A473257A791/Documents/7cafe7e7-9da9-40cd-b233-a85b0174fe00/624cbc1e-a7c5-4c0d-8937-b0a00013b2a9.pdf On iOS 17, this no longer works correctly, and although the third-party PDF editor can read our PDF, it's quite clear that it's actually using a copy. If not quite identical to what happens when LSSupportsOpeningDocumentsInPlace is false/NO, the end result is very similar (6830EDC5-F776-4BEF-8C30-046BCA1F2DF0 is Xodo's application ID): Xodo initialized document instance: <PTCoordinatedDocument: 0x2828aae00> fileURL: file:///var/mobile/Containers/Data/Application/6830EDC5-F776-4BEF-8C30-046BCA1F2DF0/Documents/Processed%20Files/624cbc1e-a7c5-4c0d-8937-b0a00013b2a9.pdf Xodo opening document: <PTCoordinatedDocument: 0x2828aae00> fileURL: file:///var/mobile/Containers/Data/Application/6830EDC5-F776-4BEF-8C30-046BCA1F2DF0/Documents/Processed%20Files/624cbc1e-a7c5-4c0d-8937-b0a00013b2a9.pdf The third-party app will immediately prompt the user to save the file, but regardless, the copy is now beyond the purview of our app so we can no longer see any changes made to it. The only workaround is to have the user explicitly share the file from the third-party app back to our app (we have the code in place to handle this), but much preferred the seamless "open-in-place" integration which did not require this. There have been vague allusions to changes in the file system in iOS 17, but we have not been able to find primary sources or much specific detail. For example: https://developer.apple.com/forums/thread/733642 https://developer.apple.com/forums/thread/737971 Are there specific changes in iOS 17 that invalidate our strategy? Are there any other things we may be missing that are needed to make this work? Note, for further reference, this issue is described in Xamarin terms here.. Although, yes, we are Xamarin developers so do not have native code to show, we (and, based on the comments, the Xamarin devs) suspect that this is most likely due to a change in iOS rather than in Xamarin.
Posted
by
Post not yet marked as solved
0 Replies
367 Views
I'm getting the following error message on on iOS 17.1 and Xcode 15.0.1 The view service did terminate with error: Error Domain=_UIViewServiceErrorDomain Code=1 "(null)" UserInfo={Terminated=disconnect method} In my info.plist I have given access to all file related permissions to rule out any issues Supports opening documents in place -> YES #if os(iOS) .fileImporter(isPresented: $isiOSFilePickerShown, allowedContentTypes: [.item], allowsMultipleSelection: false, onCompletion: { result in do{ guard let selectedURL: URL = try result.get().first else { return } guard selectedURL.startAccessingSecurityScopedResource() else { return } //Some operation with selectedURL } catch let e{ print("error reading file \(e)") } }) #endif
Posted
by