How to enable FinderSync Extension in macOS System Preferences
Asked Answered
E

3

9

I am integrating FinderSync Extension in my Cocoa Application to show badges in files and folders. Look at the below two scenario:

  1. When i run application using FinderSync Extension (like DemoFinderSync) look at the blue popup in the below image, in that case Extension is added in the System Preference with Check mark and called that principal class "FinderSync.m" as well.

Screen shot 1

  1. When i run application using my Application Scheme (like DemoApp) look at the blue popup in the below image, in that case Extension is added in the System Preference but without check mark and that principal class "FinderSync.m" do not call and FinderSync Extension does not work in this case.

Screen Shot 2

Does anybody have an idea how to enable Finder Extension in the System Preference using second scenario?

Eurus answered 2/7, 2015 at 6:24 Comment(1)
can you help me #61770616Calcicole
E
6

I got the solution:

Code to Enable Extension (bundle ID)

system("pluginkit -e use -i YourAppBundleID")

Code to Disable Extension (bundle ID)

system("pluginkit -e ignore -i YourAppBundleID")

Before i used:

system("pluginkit -e use -i AppBundleID.FinderSync")

so just remove ".FinderSync" its working.

Eurus answered 7/7, 2015 at 9:50 Comment(2)
Hi, I am facing a similar issue in my app. The application is signed by a trusted certificate but when the app is launched for the first time on a mac, the extension is not auto enabled. Any leads ?Gait
Related questions: #44118348 #44017846Gait
R
8

Non-debug scheme (#if !DEBUG):

system("pluginkit -e use -i com.domain.my-finder-extension");

When running under debugger give path to your extension directly:

NSString *pluginPath = [[[NSBundle mainBundle] builtInPlugInsPath] stringByAppendingPathComponent:@"My Finder Extension.appex"];
NSString *pluginkitString = [NSString stringWithFormat:@"pluginkit -e use -a \"%@\"", pluginPath];
system([pluginkitString cStringUsingEncoding:NSUTF8StringEncoding]);

Specify this in your applicationDidFinishLaunching method. You should also manually turn this on only once so that if user turned your extension off in the System Preferences you don't turn it on every time your application starts. I set an NSUserDefaults key the first time user launches my app that has the finder sync extension support.

Rout answered 6/7, 2015 at 22:7 Comment(4)
Its add in the system preference but do not enable as check mark as shown in second screen shot of my above posted question.Eurus
Look at man page for pluginkit and test via the command line to get it working.Rout
@Rout system("pluginkit -e use -i com.domain.my-finder-extension"); script is not working in OSX Mojave, Have you faced this issue? Can you please provide solution for that?Eurus
can you help me? #61770616Calcicole
E
6

I got the solution:

Code to Enable Extension (bundle ID)

system("pluginkit -e use -i YourAppBundleID")

Code to Disable Extension (bundle ID)

system("pluginkit -e ignore -i YourAppBundleID")

Before i used:

system("pluginkit -e use -i AppBundleID.FinderSync")

so just remove ".FinderSync" its working.

Eurus answered 7/7, 2015 at 9:50 Comment(2)
Hi, I am facing a similar issue in my app. The application is signed by a trusted certificate but when the app is launched for the first time on a mac, the extension is not auto enabled. Any leads ?Gait
Related questions: #44118348 #44017846Gait
C
0

Linking an answer I found on the Apple developer forum:

https://forums.developer.apple.com/thread/77682

When your App is outside the Sandbox, you can use:

Objective-C:

system("pluginkit -e use -i <yourFinderExtensionBundleID>");

Swift:

let pipe = Pipe()
let task = Process()
task.launchPath = "/usr/bin/pluginkit"
task.arguments = ["-e", "use", "-i", "<yourFinderExtensionBundleID>"]
task.standardOutput = pipe
let file = pipe.fileHandleForReading
task.launch()
let result = NSString(data: file.readDataToEndOfFile(), encoding:
Cowpea answered 19/9, 2018 at 22:29 Comment(1)
Also asking about the sandbox: #50172351Cowpea

© 2022 - 2024 — McMap. All rights reserved.