macOS Swift: How to properly add application as Login Item

前端 未结 4 1044
轮回少年
轮回少年 2020-12-28 19:43

I have spent about one day (maybe a little more) on trying to add my application to Login Item in the order it starts up at macOS launch (user login).

  1. The fir
4条回答
  •  情书的邮戳
    2020-12-28 20:36

    I also struggled with this a few years ago and ended up making a package for it that makes it much easier to add "launch at login" functionality for sandboxed apps.

    Instead of lots of manual steps, you just need:

    import LaunchAtLogin
    
    LaunchAtLogin.isEnabled = true
    

提交回复
热议问题