Objective c 如何在macOS系统首选项中启用FinderSync扩展
我正在Cocoa应用程序中集成FinderSync扩展,以便在文件和文件夹中显示徽章。请看以下两种情况:Objective c 如何在macOS系统首选项中启用FinderSync扩展,objective-c,cocoa,osx-yosemite,findersync,Objective C,Cocoa,Osx Yosemite,Findersync,我正在Cocoa应用程序中集成FinderSync扩展,以便在文件和文件夹中显示徽章。请看以下两种情况: 当我使用FinderSync扩展(如DemoFinderSync)运行应用程序时,请查看下图中的蓝色弹出窗口,在这种情况下,扩展将添加到带有复选标记的系统首选项中,并将该主类称为“FinderSync.m” 当我使用我的应用程序方案(如DemoApp)运行应用程序时,请查看下图中的蓝色弹出窗口,在这种情况下,系统首选项中添加了扩展,但没有复选标记,并且主体类“FinderSync.m”不调
NSString *pluginPath = [[[NSBundle mainBundle] builtInPlugInsPath] stringByAppendingPathComponent:@"My Finder Extension.appex"];
NSString *pluginkitString = [NSString stringWithFormat:@"pluginkit -e use -a \"%@\"", pluginPath];
system([pluginkitString cStringUsingEncoding:NSUTF8StringEncoding]);
在ApplicationIDFinishLaunching方法中指定此选项。您还应该手动只打开一次,这样,如果用户在系统首选项中关闭了扩展,您就不会每次启动应用程序时都打开它。用户第一次启动具有finder sync扩展支持的应用程序时,我设置了NSUserDefaults键。我得到了解决方案:
启用扩展的代码(包ID)
禁用扩展的代码(包ID)
在我使用之前:
system("pluginkit -e use -i AppBundleID.FinderSync")
所以只要删除“.FinderSync”就行了。链接我在苹果开发者论坛上找到的答案: 当您的应用程序位于沙箱外部时,您可以使用: 目标C:
system("pluginkit -e use -i <yourFinderExtensionBundleID>");
system(“pluginkit-e use-i”);
斯威夫特:
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:
let pipe=pipe()
让任务=进程()
task.launchPath=“/usr/bin/pluginkit”
task.arguments=[“-e”、“use”、“i”、“use]
task.standardOutput=管道
让file=pipe.fileHandleForReading
task.launch()
让结果=NSString(数据:file.readDataToEndOfFile(),编码:
它在系统首选项中的附加项,但不作为复选标记启用,如我上面发布的问题的第二个屏幕截图所示。查看pluginkit的手册页,并通过命令行进行测试以使其正常工作。@dbainbridge system(“pluginkit-e use-i com.domain.my finder extension”);脚本在OSX Mojave中不起作用,你遇到过这个问题吗?你能提供解决方案吗?你能帮我吗?嗨,我在我的应用程序中遇到了类似的问题。应用程序由可信证书签名,但当应用程序第一次在mac上启动时,扩展没有自动启用。有线索吗?相关问题:还有在沙箱里闲逛:你能帮我吗
system("pluginkit -e use -i AppBundleID.FinderSync")
system("pluginkit -e use -i <yourFinderExtensionBundleID>");
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: