App Store compliance for Launch at Login
mainLaunchAtLogin.isEnabled to true by default, or your app may be rejected.repository·main·Indexed 20 days ago
https://github.com/sindresorhus/launchatlogin-modernA minimal, SwiftUI-optimized API for adding 'Launch at Login' functionality to macOS apps targeting macOS 13 or later. Provides a LaunchAtLogin.Toggle view for settings scenes and the LaunchAtLogin.isEnabled property for programmatic state management.
LaunchAtLogin.isEnabled to true by default, or your app may be rejected.To add LaunchAtLogin to your macOS project, add the following URL in the “Swift Package Manager” tab in Xcode:
https://github.com/sindresorhus/LaunchAtLogin-Modern
Requirements:
https://github.com/sindresorhus/LaunchAtLogin-ModernThe easiest way to implement this functionality is to place LaunchAtLogin.Toggle() inside your app's Settings scene. The toggle manages its own state and provides a predefined label.
import SwiftUI
import LaunchAtLogin
@main
struct MyApp: App {
var body: some Scene {
Settings {
Form {
LaunchAtLogin.Toggle()
}
}
}
}You can read or write the current launch at login status using the LaunchAtLogin.isEnabled property.
import LaunchAtLogin
// Read the current state
print(LaunchAtLogin.isEnabled)
// Set the state
LaunchAtLogin.isEnabled = true
print(LaunchAtLogin.isEnabled)The LaunchAtLogin.Toggle view behaves like a standard SwiftUI Toggle but uses a predefined binding. You can override the default label ("Launch at login") by passing a string directly to the initializer or by using a ViewBuilder closure.
import SwiftUI
import LaunchAtLogin
struct SettingsScreen: View {
var body: some View {
// Using a string label
LaunchAtLogin.Toggle("Launch at login 🦄")
// Or using a ViewBuilder closure
LaunchAtLogin.Toggle {
Text("Launch at login 🦄")
}
}
}