macOS methods for applications autostarting
It is known to me that application autostart is based on different methods:
- Login elements in the System Preferences
- /Library/LaunchDaemons
- /Library/LaunchAgents
- /Users/username/Library/LaunchAgents
- /System/Library/LaunchDaemons
- /System/Library/LaunchAgents
but the Spotify application autostarts without involving any of the above folders. Its daemon is included inside the application bundle, but how does the application tell macOS to start or not this com.spotify.client.startuphelper daemon?
I can disable the starting through Spotify preferences, but it is not clear to me the method used to autostart.
Spotify uses a so-called Modern Login Item (in contrary to the deprecated Login Item).
The Modern Login Item doesn't require a classical daemon|agent.plist or a Login Item in System Preferences > Users & Groups > $USER.
Apple dev guidelines require the apps using such modern login items to provide a setting in the preferences of the app itself to disable autostart though.
AFAIU the autostart is managed with a separate autostart app in the app itself and Apple's ServiceManagement.framework. In Spotify the app is: /Applications/Spotify.app/Contents/Library/LoginItems/StartUpHelper.app
Further reading and an example app with source code (compiling requires Xcode): Modern Login Item