我想每次用戶登錄時啓動我的應用程序。LaunchAgent for GUI應用程序
我添加plist文件到/ Libray/LaunchAgents文件夾:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<false/>
<key> LaunchOnlyOnce</key>
<true/>
<key>OnDemand</key>
<false/>
<key>RunAtLoad</key>
<true/>
<key>Label</key>
<string>com.mycompany.myapp</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/mayapp.app/Contents/MacOS/myapp</string>
</array>
</dict>
</plist>
一切看起來OK,應用程序被加載,但是當我離開我的應用程序是通過的launchd服務推出回來。
我應該在我的plist文件中添加/修改哪個鍵,以防止我的應用程序不斷重新啓動。
顯然kLSSharedFileListSessionLoginItems被棄用(OS X 10.11)已經和蘋果公司建議,使用發射劑是一種更好的做法 – gbdavid 2015-10-23 07:59:18