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

84 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

Open custom file extension in my app.
Hello. I have the following question. I have a program that creates files with its own extension and reads them. When I select a file with my extension in the Files app, it automatically opens my app. But if a file with my extension is attached to an email, when I click on my file it shows me a screen with programs to open (actually it shows my program the second time I click on the file, if I click the first time, my program is not listed) . I have a question, is it possible to make the file with my extension attached to the letter immediately open in my program without additional screens or is it not allowed. If possible, then what did I miss, based on the fact that it opens immediately from the Files program. Thank you. P.S. File how it works below: ![] [Image Edited by Moderator to Remove Personal Information]
0
1
421
Apr ’24
Locking files with FileProvider on Sonoma has different behaviour than Ventura.
We're trying to implement a file locking mechanism to prevent multiple users from editing the same file at the same time causing conflicts. Our previous implementation worked well on Ventura, but on Sonoma, even when just previewing a file in Finder in Column View, as opposed to editing, it locks. This is the same behaviour we experienced with Apple's FruitBasket sample code. There is a isFileViewerRequest flag inside the NSFileProviderRequest object provided with the NSFileProviderReplicatedExtension enumerator function. We thought this would indicate a file being edited. After further investigation, we were told that the isFileViewerRequest flag just indicates if a file is being presented, not just edited. We find the intended behaviour a bit strange, why would anyone want an icon next to a file to indicate presented? Why is the behaviour working fine on Ventura as a locking mechanism but on Sonoma it can only be considered a presented mechanism? If the intended behaviour is to indicate a file being presented, why did it change behaviour going from Ventura to Sonoma? A feature that was useful in Ventura becomes useless in Sonoma and the fix is for us to adjust to a new meaning of it. My main question is the following: Is there a recommended mechanism to determine if a file is being edited so that we can implement locking to avoid simultaneous editing? Thanks
0
1
287
Mar ’24
Trying to drag from app to finder and getting this error: Sandbox extension data required immediately for flavor public.file-url, but failed to obtain.
I'm trying to make a macOS app using SwiftUI that supports dragging arbitrary files from the app into finder. However, I'm getting this error: "Sandbox extension data required immediately for flavor public.file-url, but failed to obtain." I'm looking through the entitlements and not finding anything obvious here. I've tried various forms of NSItemProvider(): Try 1: let itemProvider = NSItemProvider(item: image.data as NSSecureCoding, typeIdentifier: image.uniformType.identifier) // Tried presenting as data itemProvider.registerDataRepresentation(for: .fileURL, visibility: .all) { completion in ... } // Tried presenting as file itemProvider.registerFileRepresentation(for: .fileURL, visibility: .all) { completion in ... } Try 2: let itemProvider1 = NSItemProvider(contentsOf: tempFileUrl, contentType: .fileURL) Tried using this form as well. In the completion handler for register*Representation(), i'm typically creating a temporary file and returning that.. (either the URL to the file or the data directly, depending on the API): let tempFileUrl = URL.temporaryDirectory.appending(path: "testfile.png") _ = tempFileUrl.startAccessingSecurityScopedResource() defer { tempFileUrl.stopAccessingSecurityScopedResource() } completion(tempFileUrl as data, nil) // option 1 completion(data, nil) // option 2 Disabling App Sandbox in the entitlements file does not work, but the error message goes away. So it seems like I have two problems: some sort of entitlement error and I must be using NSItemProvider() incorrectly. Anyone have any suggestions? I don't see to many examples out there for supporting exporting files (e.g. images) from an app into Finder. Thanks!
0
0
346
Mar ’24
"DocumentPickerApp" is different from macOS to iOS & iPadOS
This sample program : @main struct DocumentPickerApp: App { var body: some Scene { DocumentGroup(newDocument: DocumentPickerDocument()) { file in ContentView(document: file.$document) } } } This sample program is running correctly on iOS, iPadOS. But this program is not running correctly on macOS. Xcode version 15.3, compile correctly all OSs, but on macOS cannot change Picker's file. I cannot understand the reason. Please tell me, the way of this problem!!
0
0
236
Mar ’24
macOS 14.4: fileproviderctl removed listproviders option
Hi all, with yesterday's macOS 14.4 update, fileproviderctl removed the listproviders option. I couldn't find a replacement. Other options like dump domain result in error: Import Cookie: Der Vorgang konnte nicht abgeschlossen werden. (GSLibraryErrorDomain-Fehler 2 - Invalid volume URL) Is there anything I can do about this except for wait for Apple to fix this? Or was removing listproviders even done intentionally? Thanks! Sebastian
6
0
758
3w
What does startaccessingsecurityscopedresource() mean for different OS?
So, I'm looking into startaccessingsecurityscopedresource() function and from my current understanding this is to get temporary access to files/folders you don't implicitly have access to i.e., that don't belong to your sandbox. I can understand what it means wrt macOS, iOS, iPadOS, but what does it mean in watchOS and tvOS where there isn't any file sharing between different apps? And what is it's relevance wrt using iCloud (if there is any?)
1
0
477
Mar ’24
Terminal Binary: "zsh: xxxx: command not found"
Hello, I'm having issues running a precompiled binary through Terminal. The binary is a custom fork of software used to send code to a microprocessor through USB. The distributor is a known company and they have the binaries working on their machine (but I don't know which version of macOS they use). I was running Ventura 13.2.1 on a 2021 M1 and upgraded to Sonoma 14.3.1 — neither worked. I'm using zsh. I symlink the location of the binary, and it returns File Exists however, when I try to run the command, I receive zsh: permission denied: command then, when I sudo the command, I receive sudo: command: command not found. If this binary is not signed by Apple, could this be the reason it's not working? Could it be because I have FileVault turned on? Are others having this issue in their applications? Thank you
1
0
1.5k
Feb ’24
how to read a file under project directory for both development and runtime?
For example I created a project aaa. aaa source folder is called aaa. that is aaa aaa/aaa then I put a data file in aaa/aaa/some.data now i want to test data in aaa/aaaTests/aaaTests.swift How can i access aaa/aaa/some.data in aaaTests.swift? If I want to access some.data inside aaa/aaa/ContentView.swift, how to write the code? I have been searching google and bing for days, but find no example answering my questions. Can anyone help me out? Thanks in advance.
1
0
552
Feb ’24
URL (via .fileImporter) to a ReadConfiguration - How to?
I've defined a FileDocument with an init(configuration: ReadConfiguration) .... I've got a URL via .fileImporter - now I'd like to actually read and process (the JSON content). How do I get the ReadConfiguration from the URL? (And what would I search for to avoid this probably trivial issue?) Of course, I wrote the JSON file in the first place... so I could just read the contents as Data and decode it to JSON. But then what is the point of FileDocument other than to provide .fileExporter with a required argument?
1
0
602
Feb ’24
NSFileProvider Extension crash on MacOS 14.4 Beta
NSFileProvider Extension based on Xamarin.Mac constantly crashes starting on MacOS 14.4 Beta Steps to Reproduce: Create simple Xamarin.Mac solution and add FileProviderExtension project Storage appears in Locations section in Finder Expected Behavior: Cloud storage shows folders content Actual Behavior: Cloud storage doesn't show folder content, just infinite running spinner FileProviderExtension process constantly crashes. It occurs only in OSX starting from 14.4 beta. Please review crash report and help me understand whats wrong and how to fix it. Simple project written with Swift and Xcode works without any issues. May be it’s related to issue described here https://forums.macrumors.com/threads/fileproviderctl-on-sonoma-14-4-here-we-f-ng-go-again.2418353. Thanks in advance! Environment-Info.log CrashReport.txt
9
0
775
Apr ’24
extendedAttributes won't sync com.apple.metadata attributes
I am trying to sync some metadata fields via NSFileProviderItem extendedAttributes and have been successful when using arbitrary tag names prefixed by "#S" This is good but pretty much useless as those fields won't be indexed by Spotlight and won't be displayed in Finder In order to have my fields displayed in Finder I am attempting to return the com.apple.metadata fields but they seem to be all systematically ignored with or without sync suffix. This is really a big limitation and surprising given the fact that the tagData call works beautifully to synchronised keywords that are then populated in the extended attributes and indexed by Spotlight. One more drop in the bucket of unanswered / undocumented questions in this forum ... Thanks for any help.
0
0
339
Jan ’24
invalidate() called during operations
Hello, I had a strange bug in a File Provider app and I found out that the problem was that NSFileProviderEnumerator's invalidate() was called during an operation (a download or even a file enumeration operation from the server). The files are stored on a server and while fetchContent is called and the extension waits for the server to send the file (or enumerate a long list of files), invalidate() is called. And after some time the extension is re-initialised. I know that the extension can be deallocated by the OS from time to time, but why during an operation? If a do a cleanup inside invalidate() I will lose references to my downloads or operations. Any thoughts on this? Is there any way to prevent this? Thank you.
0
0
352
Jan ’24
VisionOS: FileProviderUI not supported?
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.
0
0
386
Jan ’24
NSFileProviderReplicatedExtension stopped calling fetchContents
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.
0
1
352
Jan ’24
Difference between vfsStruct.f_fsid and fstat.st_ino ?
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
6
0
701
Jan ’24
Howti populate Finder comment from NSFileProviderItemProtocol extendedAttributes
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 }
0
0
373
Dec ’23
NSFileProviderReplicatedExtension: Download triggered after upload
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.
1
1
476
Jan ’24
Slow NSFileProviderEnumerator
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.
2
1
498
Dec ’23
Copy folder progress (File Provider)
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.
0
0
409
Dec ’23