In my program I need to create sockets and bind them to listen HTTP port (80). The program works fine when I launch it from command line with sudo, escalating permissions to
Xcode is able to run the debugging application as root. For this purpose the following steps should be done:
Enable the root user for local machine.
a. Run “Directory Utility” (/System/Library/CoreServices/ Directory Utility.app)
b. Choose “Enable Root User” from the Edit menu and enter the root password.
Enable remote loging.
a. In System Preferences… -> Sharing, check Remote Login. This option turns on the ssh demon.
Create ssh public/private keys and copy public key in the .ssh/authorized_keys folder for root user.
a. Open terminal on local machine and type ssh-keygen -t rsa
b. Accept the default location and type password for the root.
c. Login as root su -
and create ~/.ssh directory. (~ == /var/root)
d. Copy the public key to the root: cat ~/.ssh/id_rsa.pub | ssh root@localhost "cat - >> ~/.ssh/authorized_keys"
e. Check whether everything is Ok. Type ssh root@localhost
. It shouldn’t ask for the root password.
Enable remote debugging via ssh in Xcode.
a. Select «Get Info» from drop-down menu on «Executables».
b. In the "Debugging" settings check «Debug executable remotely via ssh» and put root@localhost as the «Connect to» info.
Everything should be Ok now ☺
From blog