Swiftpack.co - chrenn/LoginItemKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by chrenn.
chrenn/LoginItemKit 2.2.0
Add non-sandboxed macOS applications to user login items
⭐️ 28
🕓 1 year ago
.package(url: "https://github.com/chrenn/LoginItemKit.git", from: "2.2.0")

LoginItemKit

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.

Screenshot

Overview

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.

The Hide checkbox

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.

Installation

SwiftPM

.package(url: "https://github.com/chrenn/LoginItemKit", from: "2.0.0")

API

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

Usage

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

Resources

Used by

GitHub

link
Stars: 28
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

2.2.0
1 year ago
  • SMAppService and Readme note.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics