xcodemacosxcode9.2

How to run a macOS app as root and use system calls?


I'm trying to run the setpriority command from my macOS app (objective-c). It never works and I'm assuming it is because the app is not being run as the root user.

Xcode version 9.2 (9C40b)

I would appreciate any help, thanks!


Solution

  • You want to run as root, or you want to run with sudo? There's a difference. Running as root is definitely not recommended, you will get strange behaviour from the system.

    You wrote:

    I've tried opening the app with sudo

    That should work. How have you tried? You need to call the binary within the .app bundle. Running open against the bundle won't work.

    e.g.

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