Warning
With macOS 13, Apple introduced SMAppService and deprecated the Hide property.
Please use SMAppService or a wrapper like LaunchAtLogin-Modern for new projects.
A simple Swift package to add non-sandboxed macOS applications to user login items and to control their Hide property.
There are basically two ways to achieve Launch at Login functionality on macOS.
Let's compare LoginItemKit to the popular LaunchAtLogin package.
LaunchAtLogin | LoginItemKit | |
---|---|---|
Framework | ServiceManagement | LaunchServices |
Deprecated | Partly (10.10) | Yes (10.11) |
Sandbox support | Yes | No |
SwiftPM support | Yes | Yes |
Needs helper app & build script | Yes | No |
Shows up in system preferences | No | Yes |
So feel free to use this package in all your non-sandboxed apps and let's hope that Apple does not remove the LaunchServices API from future versions of macOS.
Checking Hide can cause problems for applications using high values for NSWindow.Level
, e.g. the tooltip windows in Swish. Version 2 of LoginItemKit allows you to read and write this property.
.package(url: "https://github.com/chrenn/LoginItemKit", from: "2.0.0")
LoginItemKit exposes a tertiary .launchState
enum for granular control as well as a simple .launchAtLogin
boolean.
launchState |
launchAtLogin { get, set } |
|
---|---|---|
Not in Login Items | .none |
false , false |
In Login Items & Hide checked | .hide |
true , - |
In Login Items & Hide unchecked | .show |
true , true |
import LoginItemKit
print(LoginItemKit.launchState, LoginItemKit.launchAtLogin)
// → .none, false
LoginItemKit.launchAtLogin = true
print(LoginItemKit.launchState, LoginItemKit.launchAtLogin)
// → .show, true
LoginItemKit.launchState = .hide
print(LoginItemKit.launchState, LoginItemKit.launchAtLogin)
// → .hide, true
link |
Stars: 28 |
Last commit: 1 year ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics