How do I access User Folders from Finder Sync Extension?

I am developing a Cocoa application with Finder Extension to set overlay icons on the file.



As soon as the user clicks on a folder that i am monitoring, i get a call to

the method



- beginObservingDirectoryAtURL


So my code is:


    - (void)beginObservingDirectoryAtURL:(NSURL *)url {
        // The user is now seeing the container's contents.
        // If they see it in more than one view at a time, we're only told once.
        NSLog(@"Current Path : %@", url.path);
        NSArray<NSString*>* children = [[NSFileManager defaultManager] subPathsAtPath:url.Path];
    }


The NSFileManager Default Manager path returns null when called from Finder Extension.

The same method call with the same path returns the elements in the main app.


Can I somehow enable monitoring a specific folder from Finder Extension?

Replies

Typically your app gets the root of your monitoring directory from the user (via the open panel) and passes that to your sync infrastructure via XPC, which remembers it via a security scoped bookmark.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"