I am currently making an XCode project where I plan to use SMAppService to register a launch agent so that the app can change the desktop wallpaper on a monthly basis. However, I am an amateur and have had difficulties getting the SMAppService to work. So far I have roughly followed the instructions listed in the answer here: https://developer.apple.com/forums/thread/721737
However, I still cannot get the launchd agent to run (although it does get added to the launchctl list) as I'm not fully sure how to follow those instructions. Therefore I am asking if anyone has some resources to help point me in the right direction to using the SMAppService to launch a launchAgent.
Thanks,
launchd
starts jobs on demand. The example from that other thread doesn’t set up any demand, and thus the job never starts by itself. You can synthesise demand using the start
subcommand launchctl
. In my example I do this using:
% launchctl start com.example.apple-samplecode.Test721737.agent
If you do that — making sure to use your agent’s label — does your agent start?
While it’s possible to debug launchd
agents with Xcode, I strongly encourage you to add logging to your agent. Once you agent is deployed to the Real World™, that logging will be crucial for investigating any problems that crop up. And, if you invest it good logging now, you can use it during the bring up process.
For logging hints and tips, see Your Friend the System Log.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"