How to debug launch daemons? (and a Mojave public-beta bug)


#1

I have a few scripts that run an AppleScript launch daemon to monitor a folder and perform various actions on files that get dropped into those folders. The only way I’ve ever been able to debug those daemons is by throwing a lot of display-dialog commands into them in the hope of figuring out where they break (as far as I can tell, they don’t display error messages). Is there a more efficient Script-Debugger way to debug these scripts?

One reason I ask is that the Mojave beta seems to launch a daemon into memory but then doesn’t do anything with it. I’ve created this little test application to show what happens:

https://www.dropbox.com/s/5x45qgvq20cjncs/DaemonTest.zip?dl=1

When you run it, it creates a folder on the desktop named “Drop a File Here”, then builds (on the fly) a plist file that launches the launch daemon script (included in the application bundle), and then uses that plist to launch the daemon.

Under High Sierra, when you drop a file into the “Drop a File Here” folder, the daemon displays a dialog, then moves the file to the desktop. Under Mojave, nothing happens at all.

I’ve filed a bug with Apple, but if anyone here has debugging insights, I’ll be glad to have them.