You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NSWorkspace.shared.open([url], withAppBundleIdentifier: nil, additionalEventParamDescriptor: descriptor)1 has the ability to send an Apple Event to the app being launched using the additionalEventParamDescriptor parameter. However, this method was deprecated in macOS 11 and we’re now directed to use a method that accepts NSWorkspace.OpenConfiguration2 instead. The problem is that NSWorkspace.OpenConfiguration.appleEvent only works when the app is already running, which the deprecated method didn’t require. I need the ability to send an Apple Event when launching the app, even if it’s not already running. I have tried opening the app first and then executing NSWorkspace.shared.open with the .appleEvent property, but that causes Finder to show a -50 error.
To be specific, I need this to open a sub-pane of the Extensions system preferences:
I had a DTS that's about to expire, so I decided to use it on this. Here's the reply I got:
Hi,
Let me start with a quick comment on the AppleEvent side:
let parameters = [
"action": "revealExtensionPoint",
"protocol": "com.apple.share-services"
]
let data = try? PropertyListSerialization.data(fromPropertyList: parameters, format: .xml, options: 0)
let descriptor = NSAppleEventDescriptor(descriptorType: FourCharCode(string: "ptru"), data: data)
Just so you're aware, I don't think we've ever documented that
AppleEvent configuration, so my general recommendation here would be to
now use it, since it's semantics could change or be eliminated at any
time.
I currently use the following to open a specific pane in the
Extensions system preferences. For example, the "Actions" pane.
So, the short answer is that this isn't going to work in the new API.
Let me jump to the details of the issue from your bug:
The problem is that NSWorkspace.OpenConfiguration.appleEvent only
works when the app is already running, which the deprecated method
didn’t require. I need the ability to send an Apple Event when
launching the app, even if it’s not already running. or.
This isn't really an issue, since you could use the same API to launch
the app and then send the AppleEvent after launch had finished.
However, the reason it doesn't send the AppleEvent is actually tied to
the same issue here:
I have tried opening the app first and then executing
NSWorkspace.shared.open with the .appleEvent property, but that causes
Finder to show a -50 err
The newer API is basically restricted to the open AppleEvent and doesn't
really support general AppleEvent messages. You can actually see this
in the console error message:
"-50" is "paramErr", which is triggered by an improperly constructed
AppleEvent. The "open" restriction is actually why it isn't being sent
on the initial open- the target document is delivered without the
AppleEvent in the initial launch, so there's no reason to send the
event.
While you can use the newer API to switch to a given preferences pane,
if you want to send the AppleEvent above then your only option is to
send the event yourself, though I can't promise that will work either.
Description
NSWorkspace.shared.open([url], withAppBundleIdentifier: nil, additionalEventParamDescriptor: descriptor)1 has the ability to send an Apple Event to the app being launched using theadditionalEventParamDescriptorparameter. However, this method was deprecated in macOS 11 and we’re now directed to use a method that acceptsNSWorkspace.OpenConfiguration2 instead. The problem is thatNSWorkspace.OpenConfiguration.appleEventonly works when the app is already running, which the deprecated method didn’t require. I need the ability to send an Apple Event when launching the app, even if it’s not already running. I have tried opening the app first and then executingNSWorkspace.shared.openwith the.appleEventproperty, but that causes Finder to show a-50error.To be specific, I need this to open a sub-pane of the Extensions system preferences:
The text was updated successfully, but these errors were encountered: