Download Latest Version v5.0.2 source code.tar.gz (3.5 MB)
Email in envelope

Get an email when there's a new version of LaunchAtLogin

Home / v5.0.0
Name Modified Size InfoDownloads / Week
Parent folder
README.md 2022-11-13 1.6 kB
v5.0.0 source code.tar.gz 2022-11-13 3.4 MB
v5.0.0 source code.zip 2022-11-13 3.4 MB
Totals: 3 Items   6.9 MB 0

Please read carefully

macOS 13 introduced a new API to toggle “launch at login”. We now use this new API when your app is running on macOS 13 and later.

Upgrading to this version requires migration!

You need to call LaunchAtLogin.migrateIfNeeded() at launch to migrate the enabled state to the new system. You do not need to guard this call. It can be called at every app launch. It will only ever run the migration once.

For example, for a SwiftUI app, you would call it like this:

:::swift
import SwiftUI
import LaunchAtLogin

@main
struct MyApp: App {
    init() {
        LaunchAtLogin.migrateIfNeeded()
    }

    var body: some Scene {
        WindowGroup {
            // …
        }
        Settings {
            Form {
                LaunchAtLogin.Toggle()
            }
        }
    }
}

You can remove this call when you think all users have ran the migration.

Make sure to verify that your app still launches at login on macOS 13.

If you need to rerun the migration for testing purposes, delete the LaunchAtLogin__hasMigrated UserDefaults key.

FAQ

What do I do later on when my app targets macOS 13

Remove the run script phase. It's no longer needed then.

You could also consider moving to my modern version of this package.


https://github.com/sindresorhus/LaunchAtLogin/compare/v4.2.0...v5.0.0

Source: README.md, updated 2022-11-13