How to enable FinderSync Extension in macOS System Preferences

て烟熏妆下的殇ゞ 提交于 2019-11-28 08:37:28
dbainbridge

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.

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.

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:
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!