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"
Finder Sync
RSS for tagEnhance the Finder’s user interface by adding badges, shortcut menu items, and toolbar buttons using Finder Sync.
Posts under Finder Sync tag
15 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
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.
On macOS Sequoia, the settings to enable FIFinderSync seem to have gone. I have already figured out that Extensions are no longer in the Privacy & Security section, but they are now at General › Login Items & Extensions. Here there is a Finder section, but that is just for the Finder-Extensions, not the Finder-Sync-Extensions. Those previously did not have their own section and were hidden away in the Added Extensions section that apparently no longer exists. I expect that it has been forgotten when migrating.
Where are the settings for this – have they been forgotten?
I'm unable to use third party Finder Sync Extensions on macOS 15, first beta. They do not appear in the Extensions section, that is now in System Settings - General - Login Items & Extensions.
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?
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?
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?
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.
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?
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.
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?
Can anyone tell me how to retrieve all Finder tags, including user ones that may have been synced from iCloud?
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)
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.
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