我怎样移除Swift进程消息。

huangapple go评论72阅读模式
英文:

How can I remove swift process message

问题

以下是您提供的代码的翻译部分:

每当我运行以下代码时,声音播放得很好,但它总是在控制台打印一些内容。
代码:
```swift
let path = Bundle.main.bundlePath
let task = Process()

task.launchPath = "/usr/bin/env"
task.arguments  = ["afplay", path]

let _ = try? task.run()

task.waitUntilExit()

控制台消息:

2023年5月7日 01:18:05.779125+0200 afplay[7755:301446] [plugin] AddInstanceForFactory: 没有为ID注册工厂<CFUUID 0x60000020c1c0> F8BB1C28-BAE8-11D6-9C31-00039315CD46
2023年5月7日 01:18:05.799089+0200 afplay[7755:301446] [aqme] MEMixerChannel.cpp:1636 客户端<AudioQueueObject@0x10100f200; [0]; play> 在发送格式信息时出现错误2003332927
2023年5月7日 01:18:06.554636+0200 afplay[7755:301448] [aqme] MEMixerChannel.cpp:1636 客户端<AudioQueueObject@x10100f200; [0]; play> 在发送格式信息时出现错误2003332927
您处于第一层生成

我已经提供了您要求的翻译部分,没有包含其他内容。

英文:

Whenever I run the following code, a sound is played perfectly fine but it always prints something to the console.
code:

let path = Bundle.main.bundlePath
let task = Process()
        
task.launchPath = &quot;/usr/bin/env&quot;
task.arguments  = [&quot;afplay&quot;, path]
        
let _ = try? task.run()
        
task.waitUntilExit()

console message:

2023-05-07 01:18:05.779125+0200 afplay[7755:301446] [plugin] AddInstanceForFactory: No factory registered for id &lt;CFUUID 0x60000020c1c0&gt; F8BB1C28-BAE8-11D6-9C31-00039315CD46
2023-05-07 01:18:05.799089+0200 afplay[7755:301446] [aqme]        MEMixerChannel.cpp:1636  client &lt;AudioQueueObject@0x10100f200; [0]; play&gt; got error 2003332927 while sending format information
2023-05-07 01:18:06.554636+0200 afplay[7755:301448] [aqme]        MEMixerChannel.cpp:1636  client &lt;AudioQueueObject@0x10100f200; [0]; play&gt; got error 2003332927 while sending format information
You are in First Layer spawn

I've tried clearing the terminal by running a different process with launchPath /usr/bin/clear but it still doesn't work

答案1

得分: 0

Setting task.standardOutputtask.standardErrornil 在调用 task.run() 之前,我认为会导致子进程输出到 stdout 和 stderr 的任何内容被忽略。

英文:

Setting task.standardOutput and task.standardError to nil before calling task.run(), I think will cause anything the subprocess outputs to stdout and stderr to be ignored.

huangapple
  • 本文由 发表于 2023年5月7日 07:19:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/76191597.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定