Finder Sync

RSS for tag

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

Posts under Finder Sync tag

56 Posts

Post

Replies

Boosts

Views

Activity

Spotlight / Finder Search / Finder Tags not working on virtual file system Monterey/Ventura
I'm writing a virtual file system as my educational project (generic kernel extension). Currently, mostly everything is implemented, however, I'm having trouble using Finder search and tags. The results simply don't show up - despite I am having vnop_... calls to those files. The extended attributes are supported. Inodes are stable. Mmap is implemented. Vnop_ioctl returns KERN_SUCCESS (but no implementation). An important moment: Previously, the search didn't work at all. Researching the web has shown me, that Spotlight indexation and Finder search are tightly glued. So basically I was trying to enable support for spotlight, thinking that would be the source of the problem. I was receiving "Unknown indexing state". All those tricks with mdutil, launchd, manual and reindexation either were doing nothing or returning error. The problem was resolved FOR SONOMA by making by VFS appear as local one (adding flags for MNT_LOLCAL and MNT_DOVOLFS). This has changed the state from Unknown indexing state for spotlight to Indexing is disabled. No need to turn it on for me - I am interested only in search and tags, not the spotlight itself. Basically, whether spotlight recognises my driver as no-error, the Finder works correctly, even with indexation disabled. Whether on Monterey*, or Ventura, I get the same problem. However, neither system logs nor my driver show any kinds of errors. The spotlight simply returns error. Reindexation attempt via Security&Privacy returns "Unknown error occured". The metadata for Ventura and Monterey read attempt (mdls) returns "Unable to locate file", however returns a huge list for Sonoma. *Monterey and Ventura never have .Spotlight-V100 folder. No disable indexing files or other spotlight restrictions are present. No user space solutions seem to help. The kext is unsigned and running in an environment with SIP disabled and Security Mode reduced to Permissive. Maybe there some abstract rules for what is required on VFS side to be recognised okay'ish by Spotlight ? Or maybe something specific right for my case ? Any pointers and/or assistance would be greatly appreciated.
9
0
1.4k
Jun ’24
FIFinderSync not working in iCloud Drive on Sonoma
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?
3
0
1.6k
Jun ’24
Finder Sync Extension develop in macos 14.4 but crash in macos 10.15
Hello, I am developing a Finder plugin for a MacOS application. It was working fine during development and testing on os version 14.4. However, when I tried running the application on os version 10.15, it notworking.If I run the plugin binary directly, it will crash. crash info: Time Awake Since Boot: 1100 seconds System Integrity Protection: enabled Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes: 0x0000000000000001, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Signal: Illegal instruction: 4 Termination Reason: Namespace SIGNAL, Code 0x4 Terminating Process: exc handler [719] Application Specific Information: Configuration error: Couldn't retrieve XPCService dictionary from service bundle. Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libxpc.dylib 0x00007fff71b04bfb _xpc_copy_xpcservice_dictionary.cold.1 + 14 1 libxpc.dylib 0x00007fff71af2fcd _xpc_copy_xpcservice_dictionary + 106 2 libxpc.dylib 0x00007fff71af2e27 xpc_main + 61 3 com.apple.Foundation 0x00007fff3a0a5e6f -[NSXPCListener resume] + 155 4 com.apple.pluginkit.framework 0x00007fff6258decb 0x7fff62575000 + 102091 5 com.apple.pluginkit.framework 0x00007fff6258dbf4 0x7fff62575000 + 101364 6 com.apple.pluginkit.framework 0x00007fff6258e2b2 0x7fff62575000 + 103090 7 com.apple.Foundation 0x00007fff3a11eb4c NSExtensionMain + 49 8 libdyld.dylib 0x00007fff718a5cc9 start + 1 This issue just requires creating the simplest APP project + FinderSyncExtension project in Xcode 14.4 on macOS. Set the minimum supported system to 10.15 to reproduce the issue. How can I resolve it?
16
0
1.8k
Jun ’24
Finder Sync not load when the host APP is command line APP
I'm confuse about the loading condition of Finder Sync Extension. I want to run the Finder sync as a user agent service, so I use a command line tool project and added a Finder sync extension target in the project. But when I debug the extension in Xcode, select Finder to run, the init method of Finder sync class never called, I also check the Activity Monitor, there is no the Finder sync extension. But if I use a Cocoa APP, the Finder sync extension will load as normal. So what's the condition to run a Finder Sync Extension in Finder?
0
0
757
May ’24
How to program programatically hide file and folder from Finder
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?
3
0
1.3k
Mar ’24
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
878
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/XXX-YYY So, how do I get notified when user is browsing in my FileProvider Folders?
1
2
767
Oct ’23
FileManager.containerURL(forSecurityApplicationGroupIdentifier:) returns nil on macOS
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.
4
0
1.6k
Oct ’23
Finder Sync Extension does not allow for sandboxed access
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
5
2
2.7k
Sep ’23
Can we have Finder Sync Extension on File Provider (Cloud Storage) Path macOS
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.
3
1
2.3k
Aug ’23
Finder Sync Extension: selectedItemURLs is null when used outside of the NSMenu
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)
1
0
1.8k
Jul ’23
NSXPCConnection between app and FinderSync extension
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.
6
0
2.5k
Jun ’23
FinderSync extension menu not appearing inside MS Onedrive location
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
1
0
1.3k
Jun ’23
Finder Sync Extension - Badge on Documents Folder
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?
3
0
1k
May ’23
Swift InputStream.hasBytesAvailable() returns false when reading a file on the desktop in swift how do I fix this?
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
6
1
2.2k
May ’23
Unable to obtain the same file icons as displayed in Finder for certain file types
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.
1
0
894
May ’23
How do I change to a copy-on-drag behavior (fileprovider)
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)
5
1
2.1k
Apr ’23
Try to change the privilege of server connected in Finder
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.
0
0
635
Apr ’23
iPhone doesn't show up in locations
After downloading the latest beta of iOS 18 my iPhone no longer shows up in locations in finder on my Macbook. Instructions for when it doesn't show up also didn't help.
Replies
1
Boosts
0
Views
823
Activity
Jul ’24
Spotlight / Finder Search / Finder Tags not working on virtual file system Monterey/Ventura
I'm writing a virtual file system as my educational project (generic kernel extension). Currently, mostly everything is implemented, however, I'm having trouble using Finder search and tags. The results simply don't show up - despite I am having vnop_... calls to those files. The extended attributes are supported. Inodes are stable. Mmap is implemented. Vnop_ioctl returns KERN_SUCCESS (but no implementation). An important moment: Previously, the search didn't work at all. Researching the web has shown me, that Spotlight indexation and Finder search are tightly glued. So basically I was trying to enable support for spotlight, thinking that would be the source of the problem. I was receiving "Unknown indexing state". All those tricks with mdutil, launchd, manual and reindexation either were doing nothing or returning error. The problem was resolved FOR SONOMA by making by VFS appear as local one (adding flags for MNT_LOLCAL and MNT_DOVOLFS). This has changed the state from Unknown indexing state for spotlight to Indexing is disabled. No need to turn it on for me - I am interested only in search and tags, not the spotlight itself. Basically, whether spotlight recognises my driver as no-error, the Finder works correctly, even with indexation disabled. Whether on Monterey*, or Ventura, I get the same problem. However, neither system logs nor my driver show any kinds of errors. The spotlight simply returns error. Reindexation attempt via Security&Privacy returns "Unknown error occured". The metadata for Ventura and Monterey read attempt (mdls) returns "Unable to locate file", however returns a huge list for Sonoma. *Monterey and Ventura never have .Spotlight-V100 folder. No disable indexing files or other spotlight restrictions are present. No user space solutions seem to help. The kext is unsigned and running in an environment with SIP disabled and Security Mode reduced to Permissive. Maybe there some abstract rules for what is required on VFS side to be recognised okay'ish by Spotlight ? Or maybe something specific right for my case ? Any pointers and/or assistance would be greatly appreciated.
Replies
9
Boosts
0
Views
1.4k
Activity
Jun ’24
FIFinderSync not working in iCloud Drive on Sonoma
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?
Replies
3
Boosts
0
Views
1.6k
Activity
Jun ’24
Finder Sync Extension develop in macos 14.4 but crash in macos 10.15
Hello, I am developing a Finder plugin for a MacOS application. It was working fine during development and testing on os version 14.4. However, when I tried running the application on os version 10.15, it notworking.If I run the plugin binary directly, it will crash. crash info: Time Awake Since Boot: 1100 seconds System Integrity Protection: enabled Crashed Thread: 0 Dispatch queue: com.apple.main-thread Exception Type: EXC_BAD_INSTRUCTION (SIGILL) Exception Codes: 0x0000000000000001, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Signal: Illegal instruction: 4 Termination Reason: Namespace SIGNAL, Code 0x4 Terminating Process: exc handler [719] Application Specific Information: Configuration error: Couldn't retrieve XPCService dictionary from service bundle. Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libxpc.dylib 0x00007fff71b04bfb _xpc_copy_xpcservice_dictionary.cold.1 + 14 1 libxpc.dylib 0x00007fff71af2fcd _xpc_copy_xpcservice_dictionary + 106 2 libxpc.dylib 0x00007fff71af2e27 xpc_main + 61 3 com.apple.Foundation 0x00007fff3a0a5e6f -[NSXPCListener resume] + 155 4 com.apple.pluginkit.framework 0x00007fff6258decb 0x7fff62575000 + 102091 5 com.apple.pluginkit.framework 0x00007fff6258dbf4 0x7fff62575000 + 101364 6 com.apple.pluginkit.framework 0x00007fff6258e2b2 0x7fff62575000 + 103090 7 com.apple.Foundation 0x00007fff3a11eb4c NSExtensionMain + 49 8 libdyld.dylib 0x00007fff718a5cc9 start + 1 This issue just requires creating the simplest APP project + FinderSyncExtension project in Xcode 14.4 on macOS. Set the minimum supported system to 10.15 to reproduce the issue. How can I resolve it?
Replies
16
Boosts
0
Views
1.8k
Activity
Jun ’24
Finder Sync not load when the host APP is command line APP
I'm confuse about the loading condition of Finder Sync Extension. I want to run the Finder sync as a user agent service, so I use a command line tool project and added a Finder sync extension target in the project. But when I debug the extension in Xcode, select Finder to run, the init method of Finder sync class never called, I also check the Activity Monitor, there is no the Finder sync extension. But if I use a Cocoa APP, the Finder sync extension will load as normal. So what's the condition to run a Finder Sync Extension in Finder?
Replies
0
Boosts
0
Views
757
Activity
May ’24
How to program programatically hide file and folder from Finder
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?
Replies
3
Boosts
0
Views
1.3k
Activity
Mar ’24
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.
Replies
2
Boosts
0
Views
878
Activity
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/XXX-YYY So, how do I get notified when user is browsing in my FileProvider Folders?
Replies
1
Boosts
2
Views
767
Activity
Oct ’23
FileManager.containerURL(forSecurityApplicationGroupIdentifier:) returns nil on macOS
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.
Replies
4
Boosts
0
Views
1.6k
Activity
Oct ’23
Find all Finder tags
Can anyone tell me how to retrieve all Finder tags, including user ones that may have been synced from iCloud?
Replies
2
Boosts
0
Views
1.6k
Activity
Oct ’23
Finder Sync Extension does not allow for sandboxed access
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
Replies
5
Boosts
2
Views
2.7k
Activity
Sep ’23
Can we have Finder Sync Extension on File Provider (Cloud Storage) Path macOS
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.
Replies
3
Boosts
1
Views
2.3k
Activity
Aug ’23
Finder Sync Extension: selectedItemURLs is null when used outside of the NSMenu
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)
Replies
1
Boosts
0
Views
1.8k
Activity
Jul ’23
NSXPCConnection between app and FinderSync extension
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.
Replies
6
Boosts
0
Views
2.5k
Activity
Jun ’23
FinderSync extension menu not appearing inside MS Onedrive location
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
Replies
1
Boosts
0
Views
1.3k
Activity
Jun ’23
Finder Sync Extension - Badge on Documents Folder
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?
Replies
3
Boosts
0
Views
1k
Activity
May ’23
Swift InputStream.hasBytesAvailable() returns false when reading a file on the desktop in swift how do I fix this?
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
Replies
6
Boosts
1
Views
2.2k
Activity
May ’23
Unable to obtain the same file icons as displayed in Finder for certain file types
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.
Replies
1
Boosts
0
Views
894
Activity
May ’23
How do I change to a copy-on-drag behavior (fileprovider)
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)
Replies
5
Boosts
1
Views
2.1k
Activity
Apr ’23
Try to change the privilege of server connected in Finder
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.
Replies
0
Boosts
0
Views
635
Activity
Apr ’23