FinderSync check if extension is selected

为君一笑 提交于 2019-12-03 15:09:36
pluginkit -m -A -i com.mycompany.finderExt

If the extension is enabled, the call will return

"+ com.mycompany.finderExt(1)"

If the extension is not enabled, the call will return

"- com.mycompany.finderExt(1)"

Notice the plus and minus signs, just parse the return to determine if the extension is enabled.

macOS 10.14 Mojave adds two useful new methods for Extension management:

The application hosting a Finder Sync Extension can determine whether the user has enabled the extension, and can show the UI for managing extensions. When the application becomes active again, it can check whether the user has enabled the extension.

@available(OSX 10.14, *)
open class var isExtensionEnabled: Bool { get }

@available(OSX 10.14, *)
open class func showExtensionManagementInterface()

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