Test Finder right-click feature in a desktop app using Swift

I'd like to know how to test behavior in Swift on Desktop that needs to interact with external elements, in my case the Finder.

My goal is simple: add an option in the right-click menu of the Finder that will open my application with the selected entry or entries (file or folder) from the Finder.

I have thus set the elements NSMenuItem, NSMessage, NSPortName, NSRequiredContext (NSApplicationIdentifier: com.apple.finder) etc.

I also created a class FinderService with a function performService having this declaration:

    func performService(_ pboard: NSPasteboard, userData: String, error: AutoreleasingUnsafeMutablePointer<NSString>) {
        NSLog("performService called!")
    }

And I instantiated my class like this: NSApplication.shared.servicesProvider = FinderService().

However, when I build and launch the application nothing happens, well my application runs fine and the instantiation of the class seems to be correctly called. But when I open my Finder, my action is not displayed in the right-click context menu. And in the logs of my application, no error appears. How can I test this?

Test Finder right-click feature in a desktop app using Swift
 
 
Q