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 root. Running under XCode gives a ‘permission denied’ error on the call to binding function (asio::ip::tcp::acceptor::bind()).
How can I do debugging under XCode?
All done in C++ and boost.asio on Mac OS X 10.5 with XCode 3.1.2.
Update: For Xcode 4.5 and later, see this answer instead.
The only way I’m aware of to do what you’re asking is to run Xcode as root.
Once you’re running as root, anything processes launched from Xcode will also run as root. Note, though, that if you create or edit any files, they will be owned by root, which means that you’ll have to
chownthem before you can edit them as your normal user first.I’d love a way for Xcode to say “Launch process as root”, but as far as I know, no such functionality is available.
Note that you can also run the application within the command-line debugger
gdbto debug your application. RunThen you could keep Xcode open, modify at will, and debug your program within gdb. This is what I generally do.
EDIT: Readers from the future: see the answer from Alexander Stavonin; it talks about how to do this. If you’re okay with ssh keys and enabling the root user on your system, his answer is the way to go.