Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable FinderSync Extension in macOS System Preferences

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?

like image 971
jigs Avatar asked Jul 02 '15 06:07

jigs


People also ask

How do I enable third party extensions on Mac?

Select "Security & Privacy" from the "System Preferences" window. Select the "General" tab, and select the lock in the lower left corner to allow changes. Enter your computer username and password, then select "Unlock." In the "Allow apps downloaded from:" section, select the radio button to the left of "Anywhere."

How do I find system extensions on my Mac?

Extensions, such as Markup, add extra functionality to apps, the Finder, and the Touch Bar. To change these preferences, choose Apple menu > System Preferences, then click Extensions . Extensions you installed on your Mac.

What is system extension on Mac?

System extensions work in the background to extend the functionality of your Mac. Some apps install kernel extensions, or kexts—a kind of system extension that works using older methods that aren't as secure or reliable as modern alternatives. Your Mac identifies these as legacy system extensions.


2 Answers

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.

like image 127
dbainbridge Avatar answered Sep 30 '22 08:09

dbainbridge


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.

like image 28
jigs Avatar answered Sep 30 '22 10:09

jigs