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

Files and Storage Resources
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"
0
0
1.5k
Jan ’24
How to populate the Finder comments field from NSFileProviderItemProtocol
In NSFileProviderItemProtocol I am able to use the extendedAttributes property call to add my custom extended attributes to my NSFileProviderReplicatedExtension extension files. Given that the Finder uses com.apple.metadata:kMDItemFinderComment extended attribute for file comments I thought it would be possible to populate my files with useful comments provided by the third part API. Unfortunately I seems to be unable to do so as if com.apple.metadata.... fields were inaccessible from the FP extension. Is there any way to achieve this ?
0
0
70
3d
ContentsOfDirectory for FileProvider URLs
I'm developing an iOS app. Through a .fileImporter I get access to a directory URL which might be provided by an external service like Dropbox (using a FileProvider). As the user picked the URL I have full access to it. I want to get the contents of the directory: FileManager.default.contentsOfDirectory( at: url, includingPropertiesForKeys: keys, options: [.skipsHiddenFiles] ) Unfortunately I only get whatever files the system is currently aware of, which in case of external providers is often not much. If the user opens the Apple Files app and navigates to the folder then the system gets the content from the external provider and back in my app contentsOfDirectory would show everything. What can I do to get a list of the URLs? Can I somehow trigger the system to update from the external provider? Or is there another way of handling this situation?
2
0
97
2d
Issue while accessing file from another PC on local network using document picker with SMB.
We are trying to access and copy some files [e.g., video file] from another PC on local network using SMB protocol. We found some third party libraries like AMSMB2 for this.  But we want to try to use Apple inbuilt features like File management mentioned in - https://developer.apple.com/videos/play/wwdc2019/719/ We could able to select file from SMB server using document picker in app manually. Also we got its url in debug which gets generated under "Shared" section in files app. The URL I get from document picker is -> /private/var/mobile/Library/LiveFiles/com.apple.filesystems.smbclientd/asd0QUsers/testuser/iOS/SMB_ShareFolder Now we want to avoid manual selection of file to user.We want directly open "/private/var/mobile/Library/LiveFiles/com.apple.filesystems.smbclientd/asd0QUsers/testuser/iOS/SMB_ShareFolder" path as soon as document picker opens. So that user can directly select file. But it is not working. It opens normal files app and all folders. Getting below error -  Access Shared URL directly using documentPicker "Error - CFURLResourceIsReachable failed because it was passed a URL which has no scheme" Sharing the code which I tried to open this shared folder directly :  let url = URL (string: "/private/var/mobile/Library/LiveFiles/com.apple.filesystems.smbclientd/asd0QUsers/Pranjali/iOS/SMB_ShareFolder")  let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: [UTType.folder])     documentPicker.delegate = self     documentPicker.allowsMultipleSelection = false     documentPicker.modalPresentationStyle = .custom     documentPicker.definesPresentationContext = true     documentPicker.directoryURL = url!       documentPicker.transitioningDelegate = customTransitioningDelegate    present(documentPicker, animated: true, completion: nil) I get error in console - CFURLResourceIsReachable failed because it was passed a URL which has no scheme 2024-07-05 17:49:38.501059+0530 VideoImportPOC[1327:336989] [DocumentManager] revealDocumentAtURL encountered an error: Error Domain=NSCocoaErrorDomain Code=262 "The file couldn’t be opened because the specified URL type isn’t supported." Can you please provide inputs if it is possible to access files directly in this way? or any other suggestions.
1
0
185
1w
Issue while accessing file from another PC on local network using document picker with SMB.
We are trying to access and copy some files [e.g., video file] from another PC on local network using SMB protocol. We found some third party libraries like AMSMB2 for this. But we want to try to use Apple inbuilt features like File management mentioned in - https://developer.apple.com/videos/play/wwdc2019/719/ We could able to select file from SMB server using document picker in app manually. Also we got its url in debug which gets generated under "Shared" section in files app. The URL I get from document picker is -> /private/var/mobile/Library/LiveFiles/com.apple.filesystems.smbclientd/asd0QUsers/testuser/iOS/SMB_ShareFolder Now we want to avoid manual selection of file to user. We want directly open "/private/var/mobile/Library/LiveFiles/com.apple.filesystems.smbclientd/asd0QUsers/testuser/iOS/SMB_ShareFolder" path as soon as document picker opens. So that user can directly select file. But it is not working. It opens normal files app and all folders. Getting below error - Access Shared URL directly using documentPicker "Error - CFURLResourceIsReachable failed because it was passed a URL which has no scheme" Sharing the code which I tried to open this shared folder directly : let url = URL (string: "/private/var/mobile/Library/LiveFiles/com.apple.filesystems.smbclientd/asd0QUsers/TestUser/iOS/SMB_ShareFolder") let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: [UTType.folder]) documentPicker.delegate = self documentPicker.allowsMultipleSelection = false documentPicker.modalPresentationStyle = .custom documentPicker.definesPresentationContext = true documentPicker.directoryURL = url! documentPicker.transitioningDelegate = customTransitioningDelegate present(documentPicker, animated: true, completion: nil) I get error in console - CFURLResourceIsReachable failed because it was passed a URL which has no scheme 2024-07-05 17:49:38.501059+0530 VideoImportPOC[1327:336989] [DocumentManager] revealDocumentAtURL encountered an error: Error Domain=NSCocoaErrorDomain Code=262 "The file couldn’t be opened because the specified URL type isn’t supported." Can you please provide inputs if it is possible access files directly in this way? or any other suggestions. like 1 What’s New in File Management and Quick Look - WWDC19 - Videos - Apple Developer Your iOS app can now access files stored on external devices via USB and SMB. Understand best practices for creating a document-based app...
1
0
226
1w
Is one step folder creation possible in Finder ?
I need to disallow folder renaming on my NSFileProviderReplicatedExtension extension as my foreign API system changes the asset id when a folder gets renamed and I can't retrieve or compute the new ID. For this reason I disable .allowsRenaming on folders for this volume but the Finder will still trigger the two step create "untitled folder" / rename when creating new folders. I can see that existing folders can't be renamed on the volume so the capability seems properly managed by my extension. Is there a way to prevent the creation of the "untitled folder" folder when creating new folders in Finder on a folder with renaming disabled ?
2
0
191
3d
Document Access Codes and Settings
Currently, there must be a request for access to documents with xcode, but we do not request access. Added NSDocumentDirectoryUsageDescription to info. import SwiftUI import AVFoundation import UniformTypeIdentifiers struct ContentView: View { @State private var audioPlayer: AVAudioPlayer? @State private var isPlaying = false @State private var currentFileName: String = "No file selected" @State private var showingDocumentPicker = false @State private var songList: [String] = UserDefaults.standard.stringArray(forKey: "SavedSongs") ?? [] @State private var currentSongIndex: Int = 0 var body: some View { VStack { Text(currentFileName) .font(.headline) .padding() List { ForEach(songList, id: \.self) { song in HStack { Text(song) .onTapGesture { loadAndPlaySong(named: song) } Spacer() Button(action: { removeSong(named: song) }) { Image(systemName: "trash") .foregroundColor(.red) } } } } .listStyle(PlainListStyle()) HStack(spacing: 10) { Button(action: { showingDocumentPicker = true }) { Text("Load") .font(.system(size: 12)) .frame(width: 50, height: 25) .background(Color.blue) .foregroundColor(.white) .cornerRadius(5) } .padding(.bottom, 20) } .padding() .sheet(isPresented: $showingDocumentPicker) { DocumentPicker(audioPlayer: $audioPlayer, currentFileName: $currentFileName, songList: $songList) } .onAppear { if !songList.isEmpty { loadAndPlaySong(named: songList[currentSongIndex]) } } } func playSong() { audioPlayer?.play() isPlaying = true } func pauseSong() { audioPlayer?.pause() isPlaying = false } func stopSong() { audioPlayer?.stop() audioPlayer?.currentTime = 0 isPlaying = false } func nextSong() { currentSongIndex = (currentSongIndex + 1) % songList.count loadAndPlaySong(named: songList[currentSongIndex]) } func previousSong() { currentSongIndex = (currentSongIndex - 1 + songList.count) % songList.count loadAndPlaySong(named: songList[currentSongIndex]) } func loadAndPlaySong(named songName: String) { guard let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first else { return } let fileURL = documentsURL.appendingPathComponent(songName) do { audioPlayer = try AVAudioPlayer(contentsOf: fileURL) audioPlayer?.prepareToPlay() currentFileName = songName playSong() } catch { print("Error loading file: \(error.localizedDescription)") } } func removeSong(named songName: String) { songList.removeAll { $0 == songName } UserDefaults.standard.set(songList, forKey: "SavedSongs") } } struct DocumentPicker: UIViewControllerRepresentable { @Binding var audioPlayer: AVAudioPlayer? @Binding var currentFileName: String @Binding var songList: [String] func makeCoordinator() -> Coordinator { return Coordinator(self) } func makeUIViewController(context: Context) -> UIDocumentPickerViewController { let documentPicker = UIDocumentPickerViewController(forOpeningContentTypes: [UTType.audio]) documentPicker.delegate = context.coordinator return documentPicker } func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: Context) {} class Coordinator: NSObject, UIDocumentPickerDelegate { let parent: DocumentPicker init(_ parent: DocumentPicker) { self.parent = parent } func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { guard let url = urls.first else { return } do { if url.startAccessingSecurityScopedResource() { defer { url.stopAccessingSecurityScopedResource() } let fileName = url.lastPathComponent let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first! let destinationURL = documentsURL.appendingPathComponent(fileName) if FileManager.default.fileExists(atPath: destinationURL.path) { try FileManager.default.removeItem(at: destinationURL) } try FileManager.default.copyItem(at: url, to: destinationURL) parent.audioPlayer = try AVAudioPlayer(contentsOf: destinationURL) parent.audioPlayer?.prepareToPlay() parent.currentFileName = fileName if !parent.songList.contains(fileName) { parent.songList.append(fileName) UserDefaults.standard.set(parent.songList, forKey: "SavedSongs") } } else { print("I can't get file access.") } } catch { print("An error occurred while loading the file: \(error.localizedDescription)") } } func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) { } } }
0
0
171
3w
NSFileProviderReplicatedExtension copy hooks?
My company has developed a desktop-Mac FileProvider extension which presents a user with shared encrypted folders; it's working well except for one issue. While we can handle moving an encrypted folder, there seems to be no way to detect that an encrypted folder has been copied or duplicated. Is there any equivalent to the Windows shell extension copy-hook handler, which can allow NSReplicatedFileProviderExtension (or some other portion of the system) to detect that a folder is being copied?
2
0
321
Jun ’24
File Provider Extension Fails to Launch but Still Appears on Side Bar
I am developing a Mac File Provider Extension. When testing installation from-scratch, The File Provider Name does appear on the side bar. However, the text '[App Name] encountered an unexpected error. Items may be out of date .....Try Again' appears at the top of the Finder window when opening the File Provider's Domain. Along with this text, there is a persistent 'Loading...' that is displayed in the middle of the Finder view. The File Provider seems to immediately get in a bad state. This does not happen at all during development. I am also noticing some logs in console that indicate some sort of issue. These 3 seem to be relevant. Any ideas or insight what could be going on? create-item(propagated:<root dbver:0 domver:<nil>>) why:itemChangedRemotely|diskImport sched:default.1717009685.233681#1717009069.3164978 error:<NSError: Cocoa 4101 "Couldn’t communicate with a helper application." Underlying={NSError: NSFileProviderInternalErrorDomain 7 "A connection to the extension “REMOVED ID” could not be made." Underlying={NSError: com.apple.extensionKit.errorDomain 2 "The operation couldn’t be completed. (com.apple.extensionKit.errorDomain error 2.)" UserInfo={(omitted)}}}}}>> → <requested:<p:root n:"i{31}e" dir child:0 m:rwxS ct:1717009068.969699 mt:1717009068.969699>> [duration 33ms44µs] Failed to create extensionProcess for extension 'REMOVED ID' error: Error Domain=com.apple.extensionKit.errorDomain Code=2 "(null)" UserInfo={NSUnderlyingError=0x7fa0ce9d28b0 {Error Domain=com.apple.extensionKit.errorDomain Code=2 "(null)" UserInfo={NSUnderlyingError=0x7fa0ce9d2ad0 {Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x7fa0ce9d33e0 {Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo=0x7fa0ce9d2900 (not displayed)}}}}}} Launch failed with error: Error Domain=com.apple.extensionKit.errorDomain Code=2 "(null)" UserInfo={NSUnderlyingError=0x7fa0ce9d2ad0 {Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x7fa0ce9d33e0 {Error Domain=NSPOSIXErrorDomain Code=111 "Unknown error: 111" UserInfo={NSLocalizedDescription=Launchd job spawn failed}}}}}
1
0
306
May ’24
Skip FileProvider folders without metadata
I want to traverse my local Google Drive folder to calculate the size of all the files on my drive. I'm not interested in files or directories that are not present locally. I use getattrlistbulk for traversing and it takes way too much time. I think it is because FileProvider tries to download metadata for the directories that are not yet materialised. Is there a way to skip non-materialised directories?
2
0
332
May ’24
After upgrading to macOS 14.5, the FileProvider extension is constantly restarted by the system.
When upgrading to macOS 14.5, the FileProvider extension is consistently restarted by the system. This issue was not encountered with macOS 14.0, where the FileProvider extension typically remained uninterrupted. Additionally, I observed that when adding multiple domains using the same process, only one FileProvider extension would operate in 14.0, whereas in 14.5, a separate extension runs for each domain. I haven't found any release notes mentioning this change. Is this behavior intended? I also have filled a feedback FB13810567.
1
0
296
May ’24
How to immediately cause eviction for Item upon creation?
I am developing a FileProvider extension on Mac. I was wondering what the most reliable way to evict a document as soon as possible after createItem is called for the respective item. Our use-case for this is as follows: Users can 'bulk-import' items into a FileProvider folder, and we want our application to immediately evict the item as soon as possible once the item's content is uploaded to the server. This is to save space on the user's machine. So, what is the best way to accomplish immediate eviction after item creation? I've tried calling evictItem from within the createItem function itself, but that yields many errors and can cause slowness.
3
0
418
May ’24
'iCloud' displayed when File Provider Item is marked as 'Shared'
I am developing a File Provider on Mac. I am marking some items within the domain as 'shared' via the NSFileProviderItemProtocol. However, the text 'Folder shared on iCloud by me' appears in Finder when these items are marked as shared. Is this correct? My provider has nothing to do with iCloud, which is, of course, the cloud developed by Apple. Is there a way to change this text or remove it? I've attached an image that shows the problem.
1
0
373
May ’24
Extended Attributes in File Provider Extension
I am developing a File Provider Extension on Mac. I am confused about how the extendedAttributes property works. The property never seems to be populated with any extended attributes. I've tried setting some custom extended attributes on my documents in testing, but they are never populated in the itemTemplates that are produced in the extension. The dictionary that would hold the extended attributes always is empty. I began to think that it only supported Mac-created attributes such as com.apple.quarantine. I then tried importing some files that are 'quarantined' with this appropriate extended attribute but still have not seen this data appear in my extension either. Any clarity here with what I should be expecting or what I should try would be helpful.
1
0
491
May ’24
FileProvider Testing Setup
TL:DR Can anyone provide guidance as to how to get the FileProvider testing API to work? It closes with no error and I have not been able to determine the issue despite careful attention to the documentation and signing. The Console logs seem to imply it is a Sandbox issue. Hi, Writing this as per suggested in the technical support section. I am trying to create some tests that involve controlling the calls from MacOS to the corresponding "event" functions in the FileProvider (e.g. fetchContents()) using the FileProviderExtension test API provided by Apple. I have thoroughly read the documentation (both online and within the API code) in order to get this to work. I have: Added the com.apple.developer.fileprovider.testing-mode entitlement to both my Main App as well as my FileProviderExtension Ensured my I have the correct account permissions, and provisioning profiles for my Main App as well as FileProviderExtension Added the line domain.testingModes = [.alwaysEnabled, .interactive] The issue: I found that setting the .interactive option in my domain.testingModes will result in my domain in Finder appearing to be stuck loading the root folder, and that my FileProviderExtension instance is being invalidated and closing in ~5s. It is reproducible. Is this a bug? Some things I have noticed: Attaching the debugger to the FileProviderExtension process results in no error. Additionally there is no error received when calling add(:domain). I noticed through testing that the Main App appears to be required to have the com.apple.developer.fileprovider.testing-mode entitlement in order to run a FileProviderExtension with that same entitlement. Otherwise I would receive the error: Error Domain=NSCocoaErrorDomain Code=257 "The file couldn’t be opened because you don’t have permission to view it" When trying to sign manually using a group Developer ID Application certificate as opposed to automatically with my Apple Development certificate Xcode presents the error "Main app provisioning profile" doesn't support the FileProvider Testing Mode capability." Despite this I can clearly see that is an enabled capability though the online Apple Developer portal under the Profiles section. Note that the only capabilities enabled when viewing the bundle identifiers of the Main App and FileProviderExtension are "FileProvider Testing Mode", "App Groups", and the (seemingly required) "In-App Purchases". I later realized that this was likely due to using the wrong type of provisioning profile so I generated and switched to MacOS Developer Profiles (as opposed to Distribution) and this error in XCode went away. However the above issue (FileProviderExtension instance being invalidated) persisted. If I look at the Console I see various errors from when the extension is launched till it closes: Sandbox: mdbulkimport(922) deny(1) mach-lookup com.apple.FileProvider Sandbox: hiveDiskProvider(37981) deny(1) mach-lookup com.apple.mobile.keybagd.UserManager.xpc [ERROR] Cannot query for providers. Error: NSError: Cocoa 4099 "<private>" Error from beginMonitoringProviderDomainChangesWithHandler: Error Domain=NSCocoaErrorDomain Code=4099 UserInfo={NSDebugDescription=<private>} Synchronizer coordinateReadingItemAtURL error: Error Domain=NSCocoaErrorDomain Code=3072 With the Development Provisioning Profiles I see a couple new errors: From secinitd(App Sandbox) Failed to set LS data container personality info: <private> A new error repeated a number of times from cfprefsd after trying to access some .plist files that don't appear to be on my system: Error: Couldn't open parent path due to [2: No such file or directory] Paths are: ~/Library/Containers/<extensionBundleID>/Data/Library/Preferences/ByHost/<extensionBundleID>.<ID>.plist /Library/Managed Preferences/<username>/<extensionBundleID>.plist Any help would be greatly appreciated :)
3
0
461
May ’24
When does ES_EVENT_TYPE_NOTIFY_FILE_PROVIDER_UPDATE event get raised
Description says this event will be raised when "An identifier for a process that notifies endpoint security that it is updating a file." What does this mean ? Similarly when will ES_EVENT_TYPE_NOTIFY_FILE_PROVIDER_MATERIALIZE event be raised ? Do these events get raised if any cloud provider sync app like Google Drive/Dropbox/OneDrive that usages fileprovider framework to sync the data ? In my endpoint secutiry app, I have registered for these events but i didnt receive any event *i do receive other endpoint secutiry events like ES_EVENT_TYPE_NOTIFY_CLONE etc.
0
0
379
Apr ’24
NSFileProviderManager getUserVisibleURL(for itemIdentifier: ) throws error: "The file “...” couldn’t be opened because you don’t have permission to view it."
Hello, I am encountering an error in my File Provider UI extension where, after calling NSFileProviderManager's getUserVisibleURL(for itemIdentifier: ) method, I receive an error: "The file “...” couldn’t be opened because you don’t have permission to view it." Looking at the system logs I see the following output: 2024-04-18 12:49:42.847462+0800 0x26c76 Error 0xbec93 6750 0 fileproviderd: (FileProviderDaemon) [com.apple.FileProvider:default] [ERROR] <private> is missing enumerate entitlement to lookup <private> 2024-04-18 12:49:42.847576+0800 0x26c76 Default 0xbec93 6750 0 fileproviderd: (FileProviderDaemon) [com.apple.FileProvider:default] [WARNING] No provider found with identifier <private> for calling bundle (null) on second attempt. 2024-04-18 12:49:42.847688+0800 0x26c76 Error 0xbec93 6750 0 fileproviderd: (FileProviderDaemon) [com.apple.FileProvider:default] [ERROR] Provider ID com.app.name.FileProviderExt is not allowed to provide item ID <private> to consumer ID (null) This issue only appears on my development machine with the release app bundle codesigned with the intended certificate for release. This is a machine where I have built this same application using a personal development certificate (which works fine and does not face this error). On a second Mac, which has never had this app installed, I do not face this error.
2
0
349
Apr ’24
How to show programmatically mounted network shares in Finder's sidebar
I am using NetFS's NetFSMountURLAsync api to mount SMB share in mac os app. I am able to mount the share however this share is not automatically appearing in Finder's sidebar. I tried using LSSharedFileListInsertItemURL to make the mount point available in Finder's side bar however facing crash on line, kLSSharedFileListItemBeforeFirst.takeRetainedValue() from below code snippet. let itemType: CFString = kLSSharedFileListFavoriteItems.takeRetainedValue() if let list: LSSharedFileList = LSSharedFileListCreate(nil, itemType, nil)?.takeRetainedValue() { let inPropertiesToSet: CFMutableDictionary = CFDictionaryCreateMutable(nil, 1, nil, nil) CFDictionaryAddValue(inPropertiesToSet, unsafeBitCast(kLSSharedFileListVolumesNetworkVisible, to: UnsafeRawPointer.self), unsafeBitCast(kCFBooleanTrue, to: UnsafeRawPointer.self)) let driveUrl = URL(fileURLWithPath: mountPoint) let shareUrl: CFURL = driveUrl as CFURL if let item: LSSharedFileListItem = LSSharedFileListInsertItemURL( list, kLSSharedFileListItemBeforeFirst.takeRetainedValue(), nil, iconRef, shareUrl, inPropertiesToSet, nil) { let itemRefId = LSSharedFileListItemGetID(item) let itemRefIdStr = "\(itemRefId)" userDefaults.set(itemRefIdStr, forKey: mountPoint) } } Anything wrong in above code? Also since this api is deprecated is there any alternative API to achieve this. The goal is to make the mount point available in Finder's sidebar so that user can easily access it.
2
0
417
Apr ’24
PushKit (fileProvider) calling didInvalidatePushTokenFor instead of didUpdate (credentials)
I think I've got all the keys and entitlements set up ok. I have no problem receiving normal alerts via the UNUserNotifications framework. Now I'm trying to use PushKit (for fileProvider). I have the following in my AppDelegate fileProvider = PKPushRegistry(queue: nil) fileProvider.delegate = self fileProvider.desiredPushTypes = [.fileProvider] along with the required delegate functions. I am never provided with credentials, only an immediate call to the didInvalidatePushToken delegate. Any suggestions appreciated.
0
0
346
Apr ’24