简体   繁体   中英

How to launch app's FinderSync Extension from code?

I've made finder sync extension using instruction .

It displays in finder when I launch it directly from Xcode. But it is not visible when I run the main app. Is there some way to do it for sandbox app? In not sandboxed app I used the code:

NSTask *fseEnable = [[NSTask alloc] init];
fseEnable.launchPath = @"/usr/bin/pluginkit";
fseEnable.arguments = @[@"-e", @"use", @"-i", @"com.team.AppName.FinderSyncExtension"];

[fseEnable launch];

But it does not work for sandboxed. I tried:

[[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:@"com.team.AppName.FinderSyncExtension" options:NSWorkspaceLaunchDefault additionalEventParamDescriptor:nil launchIdentifier:nil];

But It also did not work.

Probably there is some checkbox in project settings to do it. but I haven't fond it.

Also I've found probably sad news in the documentation .

After installing an app extension, a user must take action to enable it. Often, users can enable an extension within the context of their current task. If your extension is a Today widget, for example, users can edit the Today view in Notification Center to enable your extension. In other cases, users can use Settings (in iOS) or System Preferences (in macOS) to enable and manage the extensions they install.

使用int system(const char *)而不是NSTask

system("pluginkit -e use -i com.team.AppName.FinderSyncExtension");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM