How to launch Finder Sync Extension on launching the main app?
Asked Answered
A

1

5

In my Cocoa application, I have a finder sync extension.

On launching the application, my finder sync extension doesn't start automatically.

I need to go to System Preferences -> Extensions and enable it.

How do i make sure that on launch of my main application (.app) file the finder sync extension is launched and is enabled?

Alcestis answered 17/5, 2017 at 6:39 Comment(1)
Good question..Gable
U
2

Checkout https://blog.codecentric.de/en/2018/09/finder-sync-extension/

There is a section Restarting FinderSyncExtension on app launch with instructions on how to restart FinderSyncExtension on app launch and thus make it more reliable:

+ (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);
    });
}
Ulu answered 20/9, 2018 at 20:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.