Where should a daemon started by launchd store its data?
Dynamic Paths

On macOS, a process asks the operating system where to save specific types of files using the NSWorkspace method URLForDirectory:inDomain:appropriateForURL:create:error:. There is a CoreFoundation C equivalent function for this method.

This approach mimics the goals of the XDG Base Directory Specification on other platforms.

Typically /Library, however…

Before macOS 10.15, computer wide processes, such as daemons, used the /Library folder structure:


For preferences: /Library/Preferences/
For cached files: /Library/Cache/
For general support and runtime files: /Library/Application Support/


See What is the purpose of each folder under /Library and /System in Mac OS X?
 for a good overview of the various folders and their intended purpose.

However, macOS 10.15 changes the file structure and limits large parts of the core system read-only. Shipping with fixed file paths and assuming those paths to have read-write access is risky.