猴子原创,欢迎转载。转载请注明: 转载自Cocos2Der-优快云,谢谢!
原文地址: http://blog.youkuaiyun.com/cocos2der/article/details/52104828
关于Mac下如何给自己App添加开机自启动功能,你可以了解下Mac Developer Library中的说明。
There are two ways to add a login item: using the Service Management framework, and using a shared file list
Login items installed using the Service Management framework are not visible in System Preferences and can only be removed by the application that installed them.
Login items installed using a shared file list are visible in System Preferences; users have direct control over them. If you use this API, your login item can be disabled by the user, so any other application that communicates with it it should have reasonable fallback behavior in case the login item is disabled.
可以看出,Apple推荐了两种方式:Service Management framework 和 shared file list。
这两种方式有差别:
使用Service Management framework 在系统的登录项中是不可见的。只有卸载App才能移除登录项
使用 shared file list 在系统的登录项中是可见的。用户可以直接在面板上控制他们。(If you use this API, your login item can be disabled by the user, so any other application that communicates with it it should have reasonable fallback behavior in case the login item is disabled.) 原文还有一句大意是指这个API有隐患,所以在OS X 10.10系统上 API被大量Deprecated

本文介绍了如何使用Swift和Service Management framework在MacOS应用中添加开机自启动功能。通过创建一个Helper Target App,设置配置属性,并在主工程中添加启动代码,可以实现应用的自动启动。需要注意,在启用App Sandbox后,还需处理网络连接权限问题。
最低0.47元/天 解锁文章
3777

被折叠的 条评论
为什么被折叠?



