Martin Pilch
Martin Pilch

Reputation: 3305

Launch macOS app from FinderSync extension

I wrote an app that implements FinderSync extension.

Everything works fine, I can "communicate" by sending notifications through DistributedNotificationCenter from extension to main app. But obviously it works if the main app is running only.

Is there any mechanism to open terminated app and pass parameters?

UPDATE:

The idea is to implement simple image processing app. I want to run the main app (containing execution code and GUI) from Finder-Sync extension.

To be more specific I implemented func menu(for menu: FIMenuKind) -> NSMenu? of FIFinderSyncProtocol and I want to run/open main app when user right-clicks the menu item and selects operation I added into menu.

Upvotes: 2

Views: 378

Answers (2)

pkamb
pkamb

Reputation: 35032

You can use SMLoginItemSetEnabled to launch background "helper" application.

https://developer.apple.com/documentation/servicemanagement/1501557-smloginitemsetenabled

This helper app can be launched in the background by a sandboxed app with few restrictions, and kept open when then main app closes. Your FinderSync extension can continue to communicate with the helper app even if the main app is closed.

Upvotes: 0

Ivan I
Ivan I

Reputation: 9990

As I guess that my comment is at least somewhat valid, I'll put it in the answer.

Extensions allow launching of the main app by using the URL that app handles.

Communication with URL may not be enough, but you can have the app group where extension could write the data to disk and be readable by the main app or use your current way of communication with some adaptations to this method.

Upvotes: 2

Related Questions