I have an authentication app (authApp) that runs on Mac. AuthApp lets you log in to the Mac. It runs in place of the default login screen. I have added a new button in authApp and I want that button to launch another app (let's call it newApp) when clicked. AuthApp is written in Objective-C and newApp in Swift. I am able to launch newApp from the login screen every time at logout with the help of launchd agents. But that is not what I want; I want it to open only when the button in AuthApp is clicked. This is my launchd plist
`<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.example.apple-sample</string>
<key>LimitLoadToSessionType</key>
<string>LoginWindow</string>
<key>KeepAlive</key>
<true/>
<key>ProgramArguments</key>
<array>
<string>/Library/PrivilegedHelperTools/newApp.app/Contents/MacOS/newApp</string>
</array>
</dict>
</plist>`
The file is saved in /Library/LaunchAgents. newApp is in /Library/PrivilegedHelperTools. Is there a way to execute this launchd programmatically (Objective-C++/Swift) from the code so that newApp is launched? Please note this needs to be done before the user has logged in to the machine.