【问题标题】:macOS Terminal Emulator in SwiftSwift 中的 macOS 终端模拟器
【发布时间】:2017-08-07 02:04:51
【问题描述】:

我正在尝试使用 Swift 语言(目前在 Swift 4.0 上)创建终端模拟器

到目前为止,我已经创建了一个 UI,唯一的问题是我的某些命令不起作用,例如:

diskutil mount disk0s1

这会在 Xcode 控制台输出中给我以下错误:

"Could not start up a DiskManagement session"

一些命令可以工作,例如:

echo Hi

这是我目前实际执行命令的代码:

@discardableResult
func shell(_ args: String) -> Int32 {
    let task = Process()
    task.launchPath = "/usr/bin/env"
    let cmd = args.characters.split(separator: " ").map(String.init)
    task.arguments = cmd
    task.launch()
    task.waitUntilExit()
    return task.terminationStatus
}

【问题讨论】:

    标签: swift macos terminal terminal-emulator


    【解决方案1】:

    我在考虑了 5 个小时后才明白这一点。在权利文件中,您需要将 App Sandbox 更改为 NO。

    【讨论】:

    • 你有这个项目的回购链接吗? GitHub 什么的?
    猜你喜欢
    • 1970-01-01
    • 2011-08-02
    • 1970-01-01
    • 1970-01-01
    • 2014-04-29
    • 2011-06-20
    • 1970-01-01
    • 2020-09-09
    • 2019-01-25
    相关资源
    最近更新 更多