Building a macOS app that gets the currently active NSRunningApplication
.
public func findActiveApp() -> NSRunningApplication? {
for app in NSWorkspace.shared.runningApplications {
if app.isActive {
return app
}
}
return nil
}
After that, I'm just trying to terminate the application using
let app = findActiveApp()
app.terminate()
It's not terminating the application and returning false (this is for any app not just a specific one).
I have also tried app.forceTerminate()
.
Please note that I have already added my application to the Accessibility list in System Preferences.
Do you have any clue to what might be the cause of this?
Thanks!