How do I debug privileged helper? Can someone point me to documentation ?
debugging privileged helper
Three things:
Add comprehensive logging (using
) to your privileged helper. This will help you debug problems that show up in the field.os.log
For initial bring up, structure your privileged helper code so that you can debug it in a non-privileged context. There’s two parts to this:
Add an internal API your code so that you can test your core code using a standard testing harness (like XCTest).
Add command-line options to your tool so that you can debug it directly in Xcode. For example, let’s say your privileged helper tool exists to update a file in a privileged directory. Add a command-line option to override the location of that file so that, during debugging, you can point it to a location that’s not privileged.
Once you’ve done the above, you have a lot less debugging to do because you only have to deal with issues that show up when the code is run in the privileged environment. To debug those problems:
Modify your
property list to setlaunchd
. SeeWaitForDebugger
man page for details.launchd.plist
Once the tool is paused this way, attach using Debug > Attach to Process by PID or Name, setting Debug Process As to “root”.
You can now set breakpoints and continue execution.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"