首页 > 解决方案 > 当我尝试在沙盒环境中启动另一个应用程序时,MacOS 进程使我的应用程序崩溃

问题描述

我正在开发一个 MacOS 应用程序,我可以在其中打开特定 chrome 配置文件中的某些 url。

我在下面有这段代码,当我将 AppSandbox 设置为 false 但 App Store 会拒绝我的应用程序,因为应用程序沙盒已关闭。

当沙盒打开时,应用程序崩溃并出现“操作不允许”和“权限被拒绝”错误。

let commandPath = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
let arguments = ["--args", "--profile-directory=Profile 1", "https://www.google.com"]


let processUrl = URL(fileURLWithPath: commandPath)
try! Process.run(processUrl, arguments: arguments, terminationHandler: nil)

我试图用它打开 chrome,open -na "Google Chrome" ....但这也不起作用。

任何有关如何克服此问题的指导表示赞赏。

标签: swiftxcodemacos

解决方案


推荐阅读