Finder Sync

RSS for tag

Enhance the Finder’s user interface by adding badges, shortcut menu items, and toolbar buttons using Finder Sync.

Finder Sync Documentation

Pinned Posts

Posts under Finder Sync tag

17 Posts
Sort by:
Post marked as solved
3 Replies
98 Views
I'm developing an APP on Mac. There will be some template sensitive file be decrypte during the user using it. I don't want my client see these files by Finder or Terminal, so I tried to mount a file system and store the decrypted folder under the filessystem, then don't return the contents of decrypted folder when filesystem call contentsOfDirectory. It works under my filesystem. But when user directly access these files by Finder(not from my filesystem mounted path), the files are still here can be seen by the user. Is there anyway to make my files hide from Finder? Such as Finder extension, or some special folder Mac offered to store these sensitive files?
Posted
by Ere0n.
Last updated
.
Post not yet marked as solved
0 Replies
1.2k Views
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"
Posted
by eskimo.
Last updated
.
Post not yet marked as solved
0 Replies
405 Views
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.
Posted Last updated
.
Post not yet marked as solved
0 Replies
335 Views
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?
Posted Last updated
.
Post not yet marked as solved
4 Replies
575 Views
I keep getting crash reports in Xcode for one of my macOS apps published on the App Store. Actually it's not the main app that crashes, but the embedded Finder Sync extension. The crash reports indicate that this source code line static var appGroupSaveDirectoryUrl = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: identifier)!.appendingPathComponent("Library/Application Support/somedata") crashes with error Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value + 0 (<compiler-generated>:0) That line is a static variable defined in a class that is included in the main app as well as the Finder extension. The documentation reads In iOS, the value is nil when the group identifier is invalid. In macOS, a URL of the expected form is always returned, even if the app group is invalid If the documentation says that the method call can never be nil, why am I getting this crash? Is it a bug or is the documentation wrong, or am I doing something wrong? And why does the Finder Sync extension crash and not the main app? I cannot reproduce this crash with the App Store app or within Xcode and Console shows no crash reports for the app on my Mac.
Posted
by Nickkk.
Last updated
.
Post not yet marked as solved
2 Replies
1.1k Views
Can anyone tell me how to retrieve all Finder tags, including user ones that may have been synced from iCloud?
Posted Last updated
.
Post not yet marked as solved
5 Replies
1.7k Views
Hi there, Introduction I have been working on a Finder Sync extension and I would now like to use it to access a file the user has selected. This has been causing me significant issues (and I believe that a lot of other developers have also experienced similar issues with the extension). Because I plan to release my app on the App Store, I need both the main app and the finder sync app to be sandboxed Some example code describing the issue When the user executes the custom finder action in the context menu, I use the following code to extract and access the selected files: guard let target = FIFinderSyncController.default().selectedItemURLs() else { NSLog("Failed to obtain targeted URLs: %@") return }       do { //Read content of the first selected file (example) let text = try String(contentsOf: target[0], encoding: .utf8) }catch {     print("Some error occurred: \(error)") } The problem Though these files should have a sandbox exception (because they are selected by the user), they do not and I get the following error because I seemingly do not have the permission (even though I should have): Error Domain=NSCocoaErrorDomain Code=257 "The file “myfile.txt” couldn’t be opened because you don’t have permission to view it." I know from my thorough research (refer to links) that a lot of other people working with Finder Sync extensions have had this problem in the past and that Apple has not provided an official way to fix this. So essentially I am asking if Apple is planning to fix this bug in the near future or, if not, whether there is a workaround for this problem (while still passing the App Store review) and while keeping the main functionality of a context-menu like Finder Sync Extension. Useful links My previous question concerning the transfer of URLs given in the Finder Sync Extension I already asked a similar question on how to share some file URLs between my Finder Sync Extension and the Main App, to which I received a presumably working answer, which would work if this problem didn't exist. The solution to passing this access between extension and main app is to create a security scoped bookmark. This is not possible as long as I can't even access the files in the context of the extension itself. Here is the link to this aforementioned question I posted last month: Accessing a file in a sandboxed main app, which was selected in a Finder Sync Extension Some people with the same issue (dating back as far as 2016 Someone on the Apple Developer Forum had a similar issue and the respondent suggested a multitude of hacky fixes: Swift file reading permission error on macOS sandbox Here is someone on StackOverflow from someone who had the exact same issue. Multiple people mentioned there that this was a bug in the operating system and have filed multiple bug reports, which were all unanswered by Apple: Read and Write access for FinderSync extension in a sandboxed environment FinderSync Extension runtime error: The file couldn’t be opened because you don’t have permission to view it
Posted
by Elia314.
Last updated
.
Post not yet marked as solved
1 Replies
430 Views
When setting up a Finder Sync Extension, even when just using the minimal template given by the File → New → Target → macOS ones provided in Xcode, the right-click menu does not show up within iCloud Drive, while toolbar buttons always work. Outside iCloud Drive multiple extensions show up when right-clicking on Finder's background. When right-clicking inside iCloud Drive (here my synced Desktop folder), they do not show up. Before macOS Sonoma this worked perfectly for me, but it broke beginning with the first beta. No Finder extension from any app (such as the Keka one) work anymore. I have seen it discussed that not more than one Finder extension can be active in a directory, but that is not true as can be seen in the first screenshot. Q: How can I circumvent this issue?
Posted
by kamik423.
Last updated
.
Post marked as solved
3 Replies
1.4k Views
The existing project of Finder Extension is doing an amazing job in other paths but when I point it to the CloudStorage path the context menu doesn't show up. And no trace of what is going wrong any where (Xcode Logs, Console log, crash log, etc.) Path Used: /Users/<User>/Library/CloudStorage/FP-SomeDomains Yes, even my first though was, it must be because of dataless file and folders. But unfortunately it not. There was no context menu presented from my Finder Extension even on real physical files and folders.
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.3k Views
Hi there, The Setup/My Goal I have a very standard Finder Sync Extension, which extends the context menu of the finder. I also have a main application which uses the KeyboardShortcuts Package (Keyboard Shortcuts - Github) to record and save a user defined shortcut. This shortcut should execute the menu item of the Finder Sync Extension (therefore getting the selected files and processing them in some way) when used. Currently I am using inter-process communication to send an event to the extension when the shortcut is executed by the user. You can find the Swift Class responsible for the communication between Finder Sync Extension and the Main App as an Attachment here: ProcessCommunicator.swift (although the communication works and this is more an issue of the finder sync extension behaviour than one of inter-process communication). When the Finder Sync Extension receives the event, it executes the same function which is called when the user clicks the menu item like so (this event is registered in the initialisation function of the Finder Sync Extension): processCommunicator = ProcessCommunicatorReceiver(appGroupIdentifier: "group.some.bundle.id.port") processCommunicator?.on(id: 1, event: { _ in self.executeSomeAction(nil) return nil }) The same action is called when the user clicks the menu item: override func menu(for menuKind: FIMenuKind) -> NSMenu { let menu = NSMenu() if menuKind == FIMenuKind.contextualMenuForItems || menuKind == FIMenuKind.toolbarItemMenu { menu.addItem(withTitle: text, action: #selector(executeSomeAction), keyEquivalent: "T") } return menu } The function executeSomeAction would look something like this @IBAction func transfer(_ sender: AnyObject?) { guard let target = finderSyncController.selectedItemURLs() else { NSLog("Failed to obtain targeted URLs: %@") return } // Process the selected items (target) The Problem When the function executeSomeAction is called from the process-communicator-event (sent by the main app), the selectedItemURLs is nil and therefore the function returns without doing anything. If the function executeSomeAction is called by the menu item click event, the selectedItemURLs is an array of paths as expected. Is there some restriction which prevents access to the user selected, when it’s not strictly clicked by the user or am I missing something here? Other possible Solutions to my Issue This whole inter-process communication is only needed because I need the shortcut event to be sent to the extension. I have noticed that in the initialisier of the menu item there is a keyEquivalent (-> shortcut) menu.addItem(withTitle: text, action: #selector(executeSomeAction), /* HERE -->*/ keyEquivalent: "T") This shortcut seems to be ignored by the system, as it neither appears next to the menu item, nor is functional. I am assuming that this is intended but if there is any way to make this work with the inbuilt system shortcut, instead of the communication-hack I am using currently, I would prefer to use this solution. Summary As said before, the selectedItemURLs is only defined if it is called from the menu item event, which eliminates the ability to do some custom processing with the selected files (in my case called by an event sent by another process)
Posted
by Elia314.
Last updated
.
Post marked as solved
6 Replies
1.7k Views
Hello, I'm trying to get my app to communicate with a FinderSync extension using XPC. In my app, I run the listener: _xpcListener = [[NSXPCListener alloc] initWithMachServiceName:_serviceName]; _xpcListener.delegate = self; [_xpcListener resume]; Where _serviceName="a.b.c.d.e.f" In Info.plist of the app bundle, I have: keyMachServices/key dict keya.b.c.d.e.f/key true/ /dict In the FinderSync ext, I try to connect to the XPC service: _xpcConnection = [[NSXPCConnection alloc] initWithMachServiceName:_serviceName options:0]; ... [_xpcConnection resume]; It works in debug, but not when the app is installed. In this case, _xpcConnection.invalidationHandler is called. The FinderSync ext belongs to the app bundle. The .entitlements of the App: ?xml version="1.0" encoding="UTF-8"? !DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "..." plist version="1.0" dict keycom.apple.security.application-groups/key array stringa.b.c.d.e/string /array /dict /plist The .entitlements of the FinderSync: ?xml version="1.0" encoding="UTF-8"? !DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "..." plist version="1.0" dict keycom.apple.security.app-sandbox/key true/ keycom.apple.security.application-groups/key array stringa.b.c.d.e/string /array /dict /plist The app is notorized: % spctl --assess -vvvv /Applications/myApp.app                 /Applications/myApp.app: accepted source=Notarized Developer ID origin=Developer ID Application: ... In the Console, just after the start of the listener, there is this error (3 times) for myApp process: Trust evaluate failure: [leaf TemporalValidity] So I checked its certificates, but they are valid: % codesign -dvvvv --extract-certificates /Applications/myApp.app % openssl x509 -inform DER -in codesign0 -text ... Validity       Not Before: Jun 22 11:59:25 2020 GMT       Not After : Jun 23 11:59:25 2025 GMT .. % openssl x509 -inform DER -in codesign1 -text ... Validity       Not Before: Feb 1 22:12:15 2012 GMT       Not After : Feb 1 22:12:15 2027 GMT ... % openssl x509 -inform DER -in codesign2 -text ... Validity       Not Before: Apr 25 21:40:36 2006 GMT       Not After : Feb 9 21:40:36 2035 GMT ... The computer date is Ok: % date Thu Apr 8 09:20:44 CEST 2021 In the console, there is also this error for tccd process: Prompting policy for hardened runtime; service: kTCCServiceAppleEvents requires entitlement com.apple.security.automation.apple-events but it is missing for accessing={identifier=a.b.c.d.e, pid=12245, auid=501, euid=501, binary_path=/Applications/myApp.app/Contents/PlugIns/Extension.appex/Contents/MacOS/Extension}, requesting={identifier=com.apple.appleeventsd, pid=328, auid=55, euid=55, binary_path=/System/Library/CoreServices/appleeventsd}, I tried to add this com.apple.security.automation.apple-events entitlement to App and ext, but it didn't fix the problem. How can I debug this issue? Thank you.
Posted
by chrilarc.
Last updated
.
Post not yet marked as solved
1 Replies
685 Views
I have an application that uses a FinderSync extension to show a couple of my application specific menu items when User ctrl+clicks open the context menu on a file in Finder. My Menu appears everywhere except when I move a file in my company MS Onedrive sync folder. My menu items are not visible in the context menu and only MS Onedrive menu items are visible. The same happens with other findersync menu items from other apps like dropbox for example. the menu items vanish whenever a file is moved into MS OneDrive. This didn't use to happen before. Anyone facing this? Is this expected behaviour? Is any change in Mac OS or MS Onedrive may be causing this? I am using latest Mac OS Monetary 12.6.6
Posted
by tathac.
Last updated
.
Post not yet marked as solved
3 Replies
687 Views
We have a Finder sync extension to show the sync status of files and folders. However, if the uses chooses to sync the Documents folder (or Desktop or Downloads), the badge is not shown. I verified that setBadgeIdentifier:forURL is called, just like for other files/folders. So is there something special we need to do, or are those folders somehow special for the Finder?
Posted
by erikjv.
Last updated
.
Post marked as solved
6 Replies
1.1k Views
I'm creating a Swift finder sync extension that needs to read the file data into an array to send to an api but it won't read it into the array because InputStream.hasBytesAvailable() returns false so won't enter the for loop. my app requires the app sandbox which iv'e got "User Selected Files" and "Downloads" folder given read/ write access. I've also given the app full disk access in my system settings. This is my block of code causing the error specifically at the start of the While loop. let filePath = "/Users/<user>/Desktop/film.mp4" guard let inputStream = InputStream(fileAtPath: filePath) else { print("Failed to create input stream") return } // This dictates how many bytes are in each packet it must be a multiple of 327,680 let packetSize = 3276800 inputStream.open() var buffer = [UInt8](repeating: 0, count: packetSize) // Write data to bytesArray while inputStream.hasBytesAvailable{ let bytesRead = inputStream.read(&buffer, maxLength: buffer.count) if bytesRead < 0 { print("Failed to read from input stream: \(inputStream.streamError?.localizedDescription ?? "unknown error")") break } else if bytesRead == 0 { print("End of input stream reached") break } else { // Process the bytes that were read let data = Data(bytes: buffer, count: bytesRead) bytesArray.append(data) } } inputStream.close() these errors are printed in the console when i hit the button: open flag(s) 0x01000000 are reserved for VFS use and do not affect behaviour when passed to sqlite3_open_v2 cannot open file at line 46922 of [554764a6e7] os_unix.c:46922: (0) open(/private/var/db/DetachedSignatures) - Undefined error: 0 I have tried deleting the the app sandbox which can stop access to some files but when my app builds it doesn't run properly and my option doesn't appear in the context menu and no setup logs are printed to the console. It works in my first app that doesn't have an app sandbox and isn't split over two targets. Any help is much appreciated
Posted
by JamieS56.
Last updated
.
Post not yet marked as solved
1 Replies
594 Views
I am working on a macOS application, and I need to obtain the same file icons as displayed in Finder for various file types such as PDF, DOC, and others. I have tried using the following Swift code snippet: let icon = NSWorkspace.shared.icon(forFile: path) Unfortunately, this approach doesn't seem to work as expected for specific file types, like PDF and Word documents. Instead of obtaining the correct icons as displayed in Finder, I get a default white icon for these files. I have tried several alternative solutions, but none have yielded the desired results. I would appreciate any suggestions or guidance on how to obtain the correct file icons for these file types, consistent with what is displayed in Finder. First image (what I got): This is the file icon I obtained using the provided code. Notice that it is different from the one displayed in Finder, as it shows a default white icon instead of the expected file type icon. Second image (what Finder displays): This is the icon for the corresponding file as displayed in Finder. This is the icon we want to obtain through our code. Of course, I saved the obtained icon as a file using the following code. I'm not sure if this is related to the issue or not: if let iconDataResized = icon.tiffRepresentation { if let resizedImageData = NSBitmapImageRep(data: iconDataResized)?.representation(using: .png, properties: [:]) { let iconFileURL = FileManager.default.temporaryDirectory.appendingPathComponent("test.icns") try? FileManager.default.createDirectory(at: iconFileURL, withIntermediateDirectories: true, attributes: nil) try? resizedImageData.write(to: URL(fileURLWithPath: iconFileURL.path), options: .atomic) } } I have also tried this approach: let icon = NSWorkspace.shared.icon(forFileType: url.pathExtension) but the result is the same as before. Thank you in advance for your help.
Posted
by parcool.
Last updated
.
Post not yet marked as solved
5 Replies
1.6k Views
When exposing mounted volumes on a network, the user expects drag&drop to default to copy (not move from local disk). This UX is kind of standardized when connecting a thumb drive or usb ssd drive. So I find it confusing why we can't define in FileProvider the UTTypeVolume to ensure the user gets a more expected copy-on-drag behavior. Please let me know if there are ways to achieve this that I've missed. i.e. I want both "drag to" & "drag from" a file provider volume to result in the green "+" (without having to teach the user to hold the alt-key)
Posted
by jomentino.
Last updated
.
Post not yet marked as solved
0 Replies
505 Views
Try to change the privilege of server connected in Finder. Here are my steps: Open Finder, click "Go", select "connect to server". After I connected to a server and the server itself is open for "read and write". Then the system generate a disk in Locations to the sidebar of Finder. Try to modify the files in the disk, but I find that I only have the permission to read. Checking the info of the disk, the info in "Sharing & Permissions" bar said that I can only read. Then I try to change the privilege from "Ready only" to "Read and Write" of the user I am using, but the system noticed "The operation can’t be completed because you don’t have the necessary permission". I have no idea of how to change the privilege.
Posted Last updated
.