如何在macOS系统首选项中启用FinderSync扩展

时间:2022-03-13 23:26:47

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

我正在我的Cocoa应用程序中集成FinderSync扩展以显示文件和文件夹中的徽章。请看以下两种情况:

  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.
  2. 当我使用FinderSync扩展(如DemoFinderSync)运行应用程序时,请查看下图中的蓝色弹出窗口,在这种情况下,在带有复选标记的系统首选项中添加扩展,并调用该主要类“FinderSync.m”。

如何在macOS系统首选项中启用FinderSync扩展

  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.
  2. 当我使用我的应用程序方案(如DemoApp)运行应用程序时,请查看下图中的蓝色弹出窗口,在这种情况下,在系统首选项中添加扩展但没有复选标记,并且主要类“FinderSync.m”不调用和FinderSync在这种情况下,扩展功能不起作用。

如何在macOS系统首选项中启用FinderSync扩展

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

有没有人知道如何使用第二种方案在系统首选项中启用Finder扩展?

3 个解决方案

#1


7  

I got the solution:

我得到了解决方案:

Code to Enable Extension (bundle ID)

代码启用扩展(包ID)

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

Code to Disable Extension (bundle ID)

代码禁用扩展(包ID)

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

Before i used:

在我用之前:

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

so just remove ".FinderSync" its working.

所以只需删除“.FinderSync”即可。

#2


7  

Non-debug scheme (#if !DEBUG):

非调试方案(#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.

在applicationDidFinishLaunching方法中指定它。您还应该手动将其打开一次,这样如果用户在“系统偏好设置”中关闭了您的扩展程序,则每次启动应用程序时都不会将其打开。我在用户第一次启动具有finder同步扩展支持的应用时设置了NSUserDefaults键。

#3


0  

Linking an answer I found on the Apple developer forum:

链接我在Apple开发者论坛上找到的答案:

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

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

当您的应用程序位于Sandbox之外时,您可以使用:

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:

#1


7  

I got the solution:

我得到了解决方案:

Code to Enable Extension (bundle ID)

代码启用扩展(包ID)

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

Code to Disable Extension (bundle ID)

代码禁用扩展(包ID)

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

Before i used:

在我用之前:

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

so just remove ".FinderSync" its working.

所以只需删除“.FinderSync”即可。

#2


7  

Non-debug scheme (#if !DEBUG):

非调试方案(#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.

在applicationDidFinishLaunching方法中指定它。您还应该手动将其打开一次,这样如果用户在“系统偏好设置”中关闭了您的扩展程序,则每次启动应用程序时都不会将其打开。我在用户第一次启动具有finder同步扩展支持的应用时设置了NSUserDefaults键。

#3


0  

Linking an answer I found on the Apple developer forum:

链接我在Apple开发者论坛上找到的答案:

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

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

当您的应用程序位于Sandbox之外时,您可以使用:

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: