How to enable FinderSync Extension in the System Preference in Cocoa - Objective C

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), in that case Extension is added in the System Preference with Check mark and called that principal class "FinderSync.m" as well.


2) When i run application using my Application Scheme (like DemoApp) , 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.



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


Also post your answer in the below StackOverflow link:

http://stackoverflow.com/questions/31176942/how-to-enable-findersync-extension-in-the-system-preference-in-cocoa-objective


Any help is appreciated..!!

Interesting. Is that answer in the StackoverFlow post App Store approved? Are those commands publicly documented somewhere? I figured Apple would require the user to enable the Finder Sync extension, though I think it would be nice if the containing app could detect if its Finder sync extension was enabled or not to display info in the UI.

Hmm I took a look around and saw some documentation on PluginKit. However, when I attempt to run the command via NSTask from a sandboxed application, I get "unauthorized discovery flag" output.


Were you able to successfully do this from within a sandboxed application? I don't want to automatically enable my extension, but I would like to be able to check if the extension is enabled or not. If you advertise a feature, users may wonder why that feature isn't there when they run your app, so it would make sense to be able to display some kind of dialog in settings that says "Extension not enabled, this feature requires that you enable the extension in system preferences).

FinderSync extension is an "application", exactly. but its bundle is named as .appex. when you enable it in System Preferences, macOS will load it automatically (you can check by Activity app or ps -ef command)

So, you can easily check it by some code like:

runningApps = [[NSRunningApplication runningApplicationsWithBundleIdentifier:@"your.bundle.id"] retain]; 
if runningApps.count != 0{ 
// your extension was enabled
} 
else{ 
//your extension was not enabled yet
}

Basically there's two ways on how you can achieve that.

You can check if the finder sync extension is enabled or not and then open Extensions window:

if !FIFinderSyncController.isExtensionEnabled {
   FIFinderSyncController.showExtensionManagementInterface()
}

.. or you can force to turn the extension on (check the ploenne_ answer here: https://developer.apple.com/forums/thread/77682)

How to enable FinderSync Extension in the System Preference in Cocoa - Objective C
 
 
Q