我想用参数打开 FileZilla(ftp 应用程序)。
它正在与 NSTask(又名进程)一起使用:
let process:Process = Process()
process.launchPath = appURL.path
process.arguments = ["ftp://1.2.3.4"]
process.launch()
它不适用于 NSWorkspace:
try! NSWorkspace.shared().launchApplication(
at: appURL,
options: .default,
configuration: [NSWorkspaceLaunchConfigurationArguments:["ftp://1.2.3.4"]]
)
与不工作我的意思是,FileZilla 启动,但参数没有被忽略。
API 看起来很简单,但我不知道我在这里做错了什么。
我想使用 NSWorkspace 的原因是 NSTask 应用程序不会在前台启动。
我正在使用
launchAgent
来运行运行我的应用程序的脚本,我发现如果我们需要传递配置,我们需要在执行 open 函数后稍等一下:
NSWorkspace.shared.open(appURL, configuration: configuration)
Thread.sleep(forTimeInterval: 1)