Expose to the Share extension the name of the app that triggered (hosts) the extension

Originator:sindresorhus
Number:rdar://48001368 Date Originated:12-Feb-2019 11:24 PM
Status:Open Resolved:
Product:macOS + SDK Product Version:macOS 10.14.3
Classification:Enhancement Reproducible:Always
 
Summary:
I have a Share extension that needs to know which app triggered it. The extension presents a list of apps and by knowing which app triggered it, it can prioritize that app in the list by moving it to the top.

There are also other use-cases for knowing this:
- Working around an app sending buggy/weird NSExtensionItem attachments.
- Improve heuristics for which NSExtensionItem attachments and representations to pick.
- Let the user opt-into sharing which app originally made the shared item.

Steps to Reproduce:
 

Expected Results:
I expected `NSExtensionContext` to have a `.sourceApp` property with the name (or `NSRunningApplication` instance) of the host/trigger app.

Actual Results:
No property like this.

Version:
macOS 10.14.3

Notes:
My current workaround is to use `NSWorkspace.shared.frontmostApplication`, but that has timing issues.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!