StartingMyAppOnStartup

last edited January 31, 2008 08:54:10 (76.65.240.2)
CocoaDev is sponsored by: Panic: Shockingly good Mac software!

First, some terminology:

  • startup item: these run before a user logs in
  • login item: these run after a user logs in. Each user has a different set of login items.

The difference is very important. This article is about login items.

Over the years, many developers have wanted their apps to run at login. For a long time, there was no supported API to do this and various hacks were used. As of this writing, the best-practice depends on which OS version your app is running under:

Apple's documentation also details a great number of different ways to execute code at login and logout. Note that although this page doesn't say so, launchd user agents are completely broken on 10.4 and should be avoided: <http://developer.apple.com/documentation/MacOSX/Conceptual/BPSystemStartup/Articles/CustomLogin.html>

If you want to programatically determine at runtime if your app was launched because it is a login item, see KnowingIfAppWasLaunchedFromLoginItems.