SwiftProcessManager

Swift 包,用于使用 Process() 管理二进制文件的运行。

import SwiftProcessManager

let processManager = ProcessManager()
await self.processProvider.RunProces(
    url: Bundle.main.url(forResource: "bundled-binary", withExtension: nil),
    withRetry: true,                    // Retry running the binary when it exits.
    standardOutput: { output in
        print(output)
    },
    taskExitNotification: { err in
        if err != nil {
          processManager.cancel()       // Optionally stop retrying running the binary if the binary returns an error.
          print(err)
        }
    }
)