Our app uses a NSUserAppleScriptTask to capture the users context and provide contextual content. While our approach works fine for macOS High Sierra, the app thriws an error with macOS Catalina:
Script execution failed: The operation couldn’t be completed. /Users/.../Default.scpt: script error: Unknown AppleEvent address type. (-1716)
If we call the script with the Script Editor everything is fine. I assume we have to use different parameters for the NSAppleEventDescriptor for macOS Cataline. Here is the relevant code snipped:
NSAppleEventDescriptor *paramter = [NSAppleEventDescriptor listDescriptor];
[paramter insertDescriptor:[NSAppleEventDescriptor descriptorWithString:bundleId] atIndex:0];
NSAppleEventDescriptor *event = [NSAppleEventDescriptor appleEventWithEventClass:kASAppleScriptSuite
eventID:kASSubroutineEvent
targetDescriptor:nil
returnID:kAutoGenerateReturnID
transactionID:kAnyTransactionID];
[event setDescriptor:[NSAppleEventDescriptor descriptorWithString:@"getContext"] forKeyword:keyASSubroutineName];
[event setDescriptor:paramter forKeyword:keyDirectObject];
NSUserAppleScriptTask *script = [[NSUserAppleScriptTask alloc] initWithURL:scriptURL error:&fileError];
...
[script executeWithAppleEvent:event completionHandler:^(NSAppleEventDescriptor * _Nullable result, NSError * _Nullable error) {
...
}
Apples error documentation says:
-1716 | The target address type of an Apple event is unknown |
I think, Cataline doesn't accept, that the targetDescriptor parameter is nil. However the developer documentation says:
A pointer to a descriptor that identifies the target application for the Apple event. Passing
nil
results in an Apple event descriptor that has no keyAddressAttr
attribute (it is valid for an Apple event to have no target address attribute).Has someone any idea for a solution?