Programming language to develop macOS launch daemon

I'm new to macOS development (I mostly develop for Windows.) I need to develop a macOS launch daemon that would track power events and lid state of the MacBook.

Can someone let me know which programming language is it better to develop it in?

Will Swift work, or do I need something else for that?

Swift, Objective C, C, etc., it depends rather more on what the daemon is going to be doing.

Docs: https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingLaunchdJobs.html https://developer.apple.com/library/archive/technotes/tn2083/_index.html#//apple_ref/doc/uid/DTS10003794

pmset is the usual command for accessing this info, I don't know off-hand if there's an official callable interface.

Here's a semi-recent version of the pmset source code that's part of the Apple open source: https://opensource.apple.com/source/PowerManagement/PowerManagement-1132.81.1/

The Apple code is written in Objective C, and hasn't changed in a while per the comments.

Thanks. I added a comment but I think it got deleted.

Sorry, if my questions are too simple. I'm mostly a Windows developer, and there one needs to call special system functions from within a service (or a daemon.) I wonder if you need to do the same for the macOS daemon, or is it just a regular main-based executable?

Do you know any examples written in C or Swift that show how to code a simple launch daemon that resides in memory for as long as MacBook is powered on?

Programming language to develop macOS launch daemon
 
 
Q