I'm trying to launch an application using the open tool through Swift. I have two seperate implementations, one with NSWorkspace.shared.openApplication(at:configuration) for 10.15+ and one with NSWorkspace.shared.launchApplication(at:options:configuration) for 10.14 and lower. Everything works fine on 10.14 and below but Catalina is ignoring any arguments thrown at it. The app is not sandboxed.
Implementation for 10.15+:
let appPath = URL(string: "file:///usr/bin/open")!
let configuration = NSWorkspace.OpenConfiguration()
configuration.arguments = [
"-a",
executablePath,
url.absoluteString
]
NSWorkspace.shared.openApplication(at: appPath, configuration: configuration) { (app, error) in
if let error = error {
done(error)
} else {
done(nil)
}
}
Running this results in a Terminal window opening /usr/bin/open with no arguments, then closing the session.
executablePath is a string to an application's executable, e.g. /Application/Safari.app/Contents/MacOS/Safari
url is a URL object containing an http or https link
Removing file:// from appPath also works fine in 10.14, but on 10.15 results in The application “open” could not be launched because a miscellaneous error occurred.
Am I missing something?
