Xcode 调试器:cmd 行应用程序 - 从 sudo 开始?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1728827/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:56:59  来源:igfitidea点击:

Xcode debugger: cmd line application - start with sudo?

xcodemacos

提问by kent

I need to debug a command line application with Xcode... and I need to have the debugger launch my app with 'sudo'. How do I tell Xcode to do that?

我需要使用 Xcode 调试命令行应用程序...并且我需要让调试器使用“sudo”启动我的应用程序。我如何告诉 Xcode 这样做?

thx->adv

thx->adv

回答by Frank

Running XCode as root is a bad idea.

以 root 身份运行 XCode 是个坏主意。

There is an option for this in XCode (6.2):

在 XCode (6.2) 中有一个选项:

  • Product -> Scheme -> Edit Scheme
  • Select the "Run" configuration
  • Change the radio button for "Debug Process As" to "root"
  • 产品 -> 方案 -> 编辑方案
  • 选择“运行”配置
  • 将“Debug Process As”的单选按钮更改为“root”

回答by Thomas Zoechling

Have you tried starting Xcode with sudo?
The processes it spawns (gdb,...) should also run with superuser privileges:

您是否尝试过使用 sudo 启动 Xcode?
它产生的进程(gdb,...)也应该以超级用户权限运行:

sudo /Applications/Xcode.app/Contents/MacOS/Xcode

回答by Greg Hewgill

You could launch XCode itself with sudo, then it will be running with the privileges of your nominated user, and also your application would run with the same privileges.

您可以使用 启动 XCode 本身sudo,然后它将以您指定用户的权限运行,并且您的应用程序也将以相同的权限运行。

This may not be the best way; there may be a way to tell XCode to launch your application in a particular way. But the above method will work in any case.

这可能不是最好的方法;可能有一种方法可以告诉 XCode 以特定方式启动您的应用程序。但上述方法在任何情况下都有效。