在我的Cocoa应用程序中,我有一个Finder同步扩展。
启动应用程序时,我的Finder同步扩展不会自动启动。
我需要进入“系统偏好设置” -> “扩展”并启用它。
如何确保在启动我的主应用程序(.app文件)时启动并启用Finder同步扩展?
在我的Cocoa应用程序中,我有一个Finder同步扩展。
启动应用程序时,我的Finder同步扩展不会自动启动。
我需要进入“系统偏好设置” -> “扩展”并启用它。
如何确保在启动我的主应用程序(.app文件)时启动并启用Finder同步扩展?
结账 https://blog.codecentric.de/en/2018/09/finder-sync-extension/
有一个部分在应用程序启动时重新启动FinderSyncExtension,其中包含如何在应用程序启动时重新启动FinderSyncExtension
并使其更加可靠的说明:
+ (void) restart
{
NSString* bundleID = NSBundle.mainBundle.bundleIdentifier;
NSString* extBundleID = [NSString stringWithFormat:@"%@.FinderSyncExt", bundleID];
NSArray<NSRunningApplication*>* apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:extBundleID];
ASTEach(apps, ^(NSRunningApplication* app) {
NSString* killCommand = [NSString stringWithFormat:@"kill -s 9 %d", app.processIdentifier];
system(killCommand.UTF8String);
});
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t) (0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSString* runCommand = [NSString stringWithFormat:@"pluginkit -e use -i %@", extBundleID];
system(runCommand.UTF8String);
});
}