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
}
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
81 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
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.
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.
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.
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?
Hi,
Can a customized Pages document be created and integrated into an Apple Multiplatform App?
Thank you!
hi,i want to create a NSFileProviderExtension , need add file for storage, but, i create a folder, xocde show a error :
[ERROR] List of user interactions is not an array
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?
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!
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)
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 ?
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
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
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.
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?
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.
Our application which isn't a sandboxed app tries to access(copies) the file from the URL given by the file provider to the application's cache path but fails with the 'operation not permitted' error. This happens in two cases 1. File Creation & 2. File Modification.
Also, on checking the path, it is like "/Library/Application Support/FileProvider/{RandID}/wharf/wharf/propagate".
Even we tried to access the folder using a Python script and run it via the terminal but it also failed with the same error.
But when we enable the 'full disk access' option in the 'privacy & security' tab of the system settings for the application(our main app/terminal), the files can be accessed.
Our application doesn't need the 'full disk access' instead it needs permission to access the file provider extension's cache path where the temp files were stored.
How to get permissions for that folder and access the files (like setting the entitlement keys or other ways)? Or else
Is there any way to inform the system to use our application cache path as the file provider's cache path?
Any help would be appreciated.
I have a Login Item that is bundled with my .app and can run in the background. The Login Item has a File Provider extension. When a user downloads and installs a new version of the main .app, what's the correct way to handle stopping and restarting the login item and File Provider related processes to make sure they are running the latest code also?
My project has a base app which is manually signed, inside I have a FileProvider parent app and extension.
When things works elegantly in Xcode debug build when I run FP App. But, when I package it, the FileProvider can't mount, fails with a generic error on parent app
(Error Domain=NSFileProviderErrorDomain Code=-2001 "The application cannot be used right now." UserInfo={NSLocalizedDescription=The application cannot be used right now.}
Another generic error in FileProvider demon
fileproviderd(488) deny(1) file-read-data /Applications/XYZ.app/Contents/Resources/FileFP.app
How to solve this?
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"