如何在 macOS 系统偏好设置中启用 FinderSync 扩展
How to enable FinderSync Extension in macOS System Preferences
我正在将 FinderSync Extension 集成到我的 Cocoa 应用程序中以在文件和文件夹中显示徽章。看看下面的两种情况:
- 当我 运行 应用程序使用 FinderSync 扩展(如 DemoFinderSync)时,请查看下图中的蓝色弹出窗口,在这种情况下,扩展会添加到系统偏好设置中并带有复选标记并调用该主体 class "FinderSync.m" 还有。
- 当我 运行 应用程序使用我的应用程序方案(如 DemoApp)时,请查看下图中的蓝色弹出窗口,在这种情况下,扩展程序已添加到系统偏好设置中,但没有复选标记和主体 class "FinderSync.m" 不要调用,FinderSync Extension 在这种情况下不起作用。
有人知道如何使用第二种情况在系统偏好设置中启用 Finder 扩展吗?
非调试方案(#if !DEBUG):
system("pluginkit -e use -i com.domain.my-finder-extension");
当 运行 在调试器下直接为您的扩展提供路径时:
NSString *pluginPath = [[[NSBundle mainBundle] builtInPlugInsPath] stringByAppendingPathComponent:@"My Finder Extension.appex"];
NSString *pluginkitString = [NSString stringWithFormat:@"pluginkit -e use -a \"%@\"", pluginPath];
system([pluginkitString cStringUsingEncoding:NSUTF8StringEncoding]);
在您的 applicationDidFinishLaunching 方法中指定它。您还应该仅手动将其打开一次,这样如果用户在系统偏好设置中关闭了您的扩展程序,您就不会在每次应用程序启动时都打开它。我在用户第一次启动我的应用程序时设置了一个 NSUserDefaults 键,该应用程序支持查找器同步扩展。
我得到了解决方案:
启用扩展的代码(包 ID)
system("pluginkit -e use -i YourAppBundleID")
禁用扩展的代码(包 ID)
system("pluginkit -e ignore -i YourAppBundleID")
之前我用过:
system("pluginkit -e use -i AppBundleID.FinderSync")
所以只需删除“.FinderSync”即可。
链接我在 Apple 开发者论坛上找到的答案:
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:
我正在将 FinderSync Extension 集成到我的 Cocoa 应用程序中以在文件和文件夹中显示徽章。看看下面的两种情况:
- 当我 运行 应用程序使用 FinderSync 扩展(如 DemoFinderSync)时,请查看下图中的蓝色弹出窗口,在这种情况下,扩展会添加到系统偏好设置中并带有复选标记并调用该主体 class "FinderSync.m" 还有。
- 当我 运行 应用程序使用我的应用程序方案(如 DemoApp)时,请查看下图中的蓝色弹出窗口,在这种情况下,扩展程序已添加到系统偏好设置中,但没有复选标记和主体 class "FinderSync.m" 不要调用,FinderSync Extension 在这种情况下不起作用。
有人知道如何使用第二种情况在系统偏好设置中启用 Finder 扩展吗?
非调试方案(#if !DEBUG):
system("pluginkit -e use -i com.domain.my-finder-extension");
当 运行 在调试器下直接为您的扩展提供路径时:
NSString *pluginPath = [[[NSBundle mainBundle] builtInPlugInsPath] stringByAppendingPathComponent:@"My Finder Extension.appex"];
NSString *pluginkitString = [NSString stringWithFormat:@"pluginkit -e use -a \"%@\"", pluginPath];
system([pluginkitString cStringUsingEncoding:NSUTF8StringEncoding]);
在您的 applicationDidFinishLaunching 方法中指定它。您还应该仅手动将其打开一次,这样如果用户在系统偏好设置中关闭了您的扩展程序,您就不会在每次应用程序启动时都打开它。我在用户第一次启动我的应用程序时设置了一个 NSUserDefaults 键,该应用程序支持查找器同步扩展。
我得到了解决方案:
启用扩展的代码(包 ID)
system("pluginkit -e use -i YourAppBundleID")
禁用扩展的代码(包 ID)
system("pluginkit -e ignore -i YourAppBundleID")
之前我用过:
system("pluginkit -e use -i AppBundleID.FinderSync")
所以只需删除“.FinderSync”即可。
链接我在 Apple 开发者论坛上找到的答案:
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: