How to stop an app from launching on Login? I have created an app, that sets itself to launch at Login using SMLoginItemSetEnabled. Here is the code it uses. My question is, how can I manually remove this app from launching at login?

The app does not show under "Login Items", or /Library/LaunchAgents, or /Library/LaunchDaemons or in the /Users/username/Library/LaunchAgents, or /Users/username/Library/LaunchDaemons folders. I looked around in /Library/Preferences and PreferecePanes, but I found nothing. The app does load on login.
You can stop the item from launching with launchctl disable gui/$UID/bundle-id.

If you don't know the bundle ID, you can find it by typing launchctl list. That will list all processes running under your user, with their PIDs in the first column. So, if you saw this:

$ launchctl list
-   0   com.apple.SafariHistoryServiceAgent
277 0   com.apple.Finder
-   0   com.apple.quicklook
-   0   com.apple.parentalcontrols.check
[…]
189 0   com.example.ExampleDaemon
-   0   com.apple.java.InstallOnDemand


…you could use Activity Monitor to confirm that the unwanted app's PID is 189, which makes its bundle ID com.example.ExampleDaemon. Then:

launchctl disable gui/$UID/com.example.ExampleDaemon


That's it. There is still a record of the login item on disk, just disabled. If you want to purge it, or just want to learn more, read on.



Counterintuitively (but amusingly?), the list is saved here:

/var/db/com.apple.xpc.launchd/disabled.$UID.plist


That file will look something like this:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
    &lt;key&gt;com.example.ExampleDaemon&lt;/key&gt;
    &lt;false/&gt;
&lt;/dict&gt;
&lt;/plist&gt;


Yes, the false means that an app with that bundle id should be launched at startup. After running launchctl disable, the false will change to a true. (As far as I can tell, launchd doesn't write these files right away, so you may not see this until you reboot.) You can see the disabled items with this command:

launchctl print-disabled gui/$UID


There's also some extra info about each login item stored here, but removing it won't stop the item from launching:

/var/db/com.apple.xpc.launchd/loginitems.$UID.plist


Any changes you make while the system is running will be overwritten when you shut down/restart. So, as far as I can tell, the only way to completely remove an item from disabled.$UID.plist is to reboot in single user mode and make the edits there. Even without having run launchctl disable, removing a key/false pair from this file stops the app from launching at login. I'm not going to include instructions for editing these files in single user mode in this answer.