Send Apple Event DO NOT show automation permission dialog when using JUCE GUI Application

I try to send an apple event using Carbon framework.

Following the apple development guide
1. include Carbon.h and Carbon.framework into MACOSX APP
2. Using AECreateDesc, AECreateAppleEvent, AESend and so on, to create and send Apple Event

so, I create a new JUCE Console App, and following the guide, when I run the app, an “Automation Permission” dialog was shown, and all works fine.

then, I create a new JUCE GUI App, and using the same code and steps, none errors or warings occured when I buiding the project, but there is not any permission dialog show, and the apple event also not send, although the application successfully running.

when I use /JUCE/example/CMake template to create a CMake GuiAPP by CLion, and "target_link_library(MyApp PUBLIC “-framework Carbon”), the perission dialog also not showing.

I also try to enable the “Send Apple Events” and “Send Apple Events Text” in Projucer.

Here is my Apple Event Code

#include <iostream>
#include <Carbon/Carbon.h>

AEAddressDesc processAEAddressDesc;  // Destination
AppleEvent appleEventToSend,appleEventReply; // Send Event & Response Event, NO REPLY
OSErr osError = noErr;
OSType PangSignature = 'PANG'; // Destination NAME

// Create Event Description
if(osError == noErr)
    osError = AECreateDesc(typeApplSignature, &PangSignature, sizeof(PangSignature), &processAEAddressDesc);

// Create an apple event to send
if(osError == noErr)
    // Custom Apple Event and Type Sd2a&SRgn
    osError = AECreateAppleEvent('Sd2a','SRgn', &processAEAddressDesc, kAutoGenerateReturnID,kAnyTransactionID, &appleEventToSend);

// Create a NULL reply event because we don't expect any reply
if(osError == noErr) 
    osError = AECreateDesc(typeNull, NULL, 0, &appleEventReply);

// Send Event
if(osError == noErr) 
    osError = AESend(&appleEventToSend, &appleEventReply, kAEWaitReply|kAECanInteract,kAENormalPriority, kAEDefaultTimeout,NULL, NULL);

I suspect you may need to declare that your app uses Apple Events in its plist:

If using the Projucer to manage your project, you can add this key to the “Custom Plist” field for the Xcode exporter. If using CMake, you can use the PLIST_TO_MERGE argument to the juce_add_* functions. In both cases, the string to supply might look like this:

    <string>This app needs to use Apple Events in order to function correctly.</string>

Thx for your help, follow your guide, I add those xml string to info.plist file, and it’s still not working well.

However, I found maybe there need another key for send apple event, so I use the following string and success!!!~~~

<plist version="1.0">
    <key>LSPrefersCarbon</key> <!-- USING CARBON ENVIRONMENT --!>

And, this issue only appears on GUI mode