使用 SMLoginItemSetEnabled,应用程序不会显示在“登录项”下

Tar*_*ill 5 macos xcode objective-c

我正在使用SMLoginItemSetEnabled登录时启动应用程序。一切正常,只是应用程序没有显示在“用户首选项”窗口的“登录项”下。我已经在 OS X Lion 中尝试过这个。

  1. 这是预期的行为吗?
  2. 有没有办法手动阻止应用程序在登录时启动?我在/Library/LaunchDaemons或 中找不到任何东西/Library/LaunchAgents

Zec*_*umo 9

这是预期的行为。 Apple Daemons and Services Programming Guide说:

使用服务管理框架安装的登录项在系统偏好设置中不可见,只能由安装它们的应用程序删除。


是的,只需将 launchd 的 overrides.plist 中的包标识符的 Disabled 更改为 true。我给你写了一个命令来做到这一点:

/usr/libexec/PlistBuddy -c 'Set :com.yourcompany.helper-CFBundleIdentifier-here:Disabled true' /var/db/launchd.db/com.apple.launchd.peruser.$UID/overrides.plist
Run Code Online (Sandbox Code Playgroud)
  • 注意:将 com.yourcompany.helper-CFBundleIdentifier-here 替换为您的 BundleIdentifier。

  • 注意:看起来 10.10 现在使用 `/var/db/com.apple.xpc.launchd/disabled.$UID.plist` 来跟踪启用/禁用状态。 (6认同)