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

Getting FruitBasket File Provider Demo to run
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?
1
0
363
Dec ’23
problem with .FileImporter in fisical divice
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?
6
0
650
Nov ’23
Cannot Evict Items from File Provider
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!
1
0
735
Nov ’23
Download a file in a File Provider Extension in iOS
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)
3
0
737
Nov ’23
`fetchContents(for:version:request:completionHandler:)` get the requesting executable name
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 ?
2
0
516
Mar ’24
Download a file in a File Provider Extension in iOS
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
1
1
603
Nov ’23
How to change displayName for a Replicated File Provider extension domain on macOS?
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
0
0
291
Nov ’23
Get all local music from iPhone Same Like UIDocumentPicker Without UserInteraction
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.
0
0
533
Nov ’23
Files shared for "open-in-place" editing not working correctly in iOS 17
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.
5
2
871
Nov ’23
Issue with importing files from File browser to the app via SwiftUI
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
0
0
442
Nov ’23
Changing Default Folder Name in Files App for iOS App
Hello, I'm working on an iOS app called "scribe-frontend-ios," and I'd like to change the default folder name that the app creates in the Files app on iOS. Currently, when the app saves files to the Files app, they all go into a folder named "scribe-frontend-ios." However, I want to just call this folder Scribe. I've tried modifying the Info.plist file in my Xcode project by adding the "NSFileProviderServiceName" key with a custom folder name, but it doesn't seem to have any effect. I've also set "LSSupportsOpeningDocumentsInPlace" to true to indicate that my app supports opening documents in place. Can someone please provide guidance on how to change the default folder name for the app in the Files app? Is there a step I might be missing, or is there another way to achieve this? Any help or advice would be greatly appreciated. Thank you!
0
0
418
Oct ’23
FIFinderSync and NSFileProviderReplicatedExtension together
Can these FIFinderSync and NSFileProviderReplicatedExtension work together? My app contains FIFinderSync Extension for files and folders to show Overlay icons. Recently I implemented FileProviderExtension to get the power of cloudsync. As both of them are bundled at the same location Contents/PlugIns/. Only the FileProviderExtensions work. Both have the same NSExtensionPointIdentifers, one uses com.apple.findersync while another one com.apple.fileprovider-nonui. Is this a limitation or what do I need to do so that both work together? Edit: I just noticed, FinderExt and FileProviderExt keeps switching/swapping in between. So both work in parts. But not together.
2
0
596
Oct ’23
FileProvider conflicts: how to have a rename or move operation win when an item is deleted remotely?
Using the File Provider API on macOS, I would like to ensure that renaming or moving an item locally wins when the same item is conflictingly deleted remotely. The default behavior seems to be that the delete wins in these two scenarios (compared to local edits, where the item is recreated in response to the conflict (createItem is called following the enumeration of the remote deletion)). Is there a way for my file provider to indicate that the system should recreate the now modified item following my handling of the deletion? The intended behavior can be observed with iCloud, by taking your Mac offline and renaming or moving an item. Before bringing the Mac back online, permanently delete the same item from another device. Many thanks.
0
0
321
Oct ’23
How to handle FileProvider notAuthenticated error in macOS?
I am running a similar code in FileProvider extension, which throws an notAuthenticated error if the user is not logged in. How do I make user to launch the parent app for the authentication? func enumerateItems(for observer: NSFileProviderEnumerationObserver, startingAt page: NSFileProviderPage) { if(isSignedOut){ observer.finishEnumeratingWithError(NSFileProviderError(.notAuthenticated)) return } } And in the Finder it shows The right corner has Sign in button how do get action control of that button?
1
0
379
Oct ’23
FileProvider's eviction is failing with resource busy error though no file is open
I have applied content policy as "downloadEagerlyAndKeepDownloaded" on the folder which i want to materialise (want to implement windows similar feature Always keep on this device feature in mac os in FileProvider). For root item the policy is downloadLazily and for rest of the item it is inherited. The issue i am facing is, while dematerialising the folder, the file provider'e evictItem api is continuously failing with resource busy error though there is no file from that folder in an open state. And it keeps giving the same error and unable to dematerialise that folder.
1
0
515
Oct ’23
How to get user browsing directory from FileProvider Extension macOS?
The goal is to get the current directory when user is browsing and get the updates from the server and populate using enumerateChanges. There is no trigger natively from FileProvider Extension that I can make use of, if there is anything I missed please let me know. I have also tried FInderSyncExtension and pointed it to the CloudStorage path, while it worked flawlessly in the other location but not in CloudStorage location ~/Library/CloudStorage/***-YYY So, how do I get notified when user is browsing in my FileProvider Folders?
1
2
519
Oct ’23