How to make the app run as root and pop a window up requires your password?

I need to run some commands with system("");

but it said no permission.

but i don't want to run sudo /Applications/AppName/contents/Mac OS/AppName everytime.

Do you have good method to solve this?

Thanks.

but i don't want to run

sudo /Applications/AppName/Contents/MacOS/AppName
everytime.

Indeed. Running your whole app as root is a very bad idea.

Can you explain more about the context here. For example:

  • What commands do you want to root?

  • What is your minimum deployment target?

  • What is your distribution model? Mac App Store? Or Developer ID?

  • If it’s the latter, is this intended to be distributed to a large number of users? Or just something you plan to use internally?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
How to make the app run as root and pop a window up requires your password?
 
 
Q