Hello.
As described in the title - NSWorkspace launch and activate application despite activates property of OpenConfiguration set to false. I want to launch Safari Extension Container (main application) as helper:
func launchMainApp() {
guard let mainAppAsHelperURL = NSWorkspace.shared.urlForApplication(withBundleIdentifier: mainAppBundleIdentefier) else { return }
let openConfiguration = NSWorkspace.OpenConfiguration()
openConfiguration.activates = false
NSWorkspace.shared.openApplication(at: mainAppAsHelperURL, configuration: openConfiguration, completionHandler: { mainApp, err in
if let error = err {
DispatchQueue.main.async {
let alert = NSAlert(error: error)
alert.runModal()
}
} else {
Self.mainApp = mainApp
}
})
}
The Safari Extension have popover. Launching helper performed when the popover shown:
override func popoverWillShow(in window: SFSafariWindow) {
if Self.mainApp == nil {
log(name: "Launch Mainapp as helper", t: "")
launchMainApp()
}
}
The popover opens and immediately closes and Safari becomes inactive. This is not the result I was expecting. But this happening when application installed from TestFlight. When i build app on my mac and open extension’s popover by clicking icon in Safari toolbar everything ok, helper launches and popover stay opened.
Please help me resolve these issues. Thank you.