Add “Launch at Login” functionality to your macOS app in seconds

Overview

LaunchAtLogin

Add “Launch at Login” functionality to your macOS app in seconds

It's usually quite a convoluted and error-prone process to add this. No more!

This package works with both sandboxed and non-sandboxed apps and it's App Store compatible and used in apps like Plash, Dato, Lungo, and Battery Indicator.

Requirements

  • macOS 10.12+
  • Xcode 12+
  • Swift 5.3+

Install

Swift Package Manager

Add https://github.com/sindresorhus/LaunchAtLogin in the “Swift Package Manager” tab in Xcode.

Carthage

Warning: Carthage is not recommended. Support for it will be removed at some point in the future.

github "sindresorhus/LaunchAtLogin"

Usage

Swift Package Manager

Add a new “Run Script Phase” below (not into) “Copy Bundle Resources” in “Build Phases” with the following:

"${BUILT_PRODUCTS_DIR}/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/copy-helper-swiftpm.sh"

(I would name the run script Copy “Launch at Login Helper”)

Carthage

Add a new “Run Script Phase” below (not into) “Embed Frameworks” in “Build Phases” with the following:

"${PROJECT_DIR}/Carthage/Build/Mac/LaunchAtLogin.framework/Resources/copy-helper.sh"

(I would name the run script Copy “Launch at Login Helper”)

Use it in your app

No need to store any state to UserDefaults.

Note that the Mac App Store guidelines requires “launch at login” functionality to be enabled in response to a user action. This is usually solved by making it a preference that is disabled by default. Many apps also let the user activate it in a welcome screen.

As static property

import LaunchAtLogin

print(LaunchAtLogin.isEnabled)
//=> false

LaunchAtLogin.isEnabled = true

print(LaunchAtLogin.isEnabled)
//=> true

SwiftUI

This package comes with a LaunchAtLogin.Toggle view which is like the built-in Toggle but with a predefined binding and label. Clicking the view toggles “launch at login” for your app.

struct ContentView: View {
	var body: some View {
		LaunchAtLogin.Toggle()
	}
}

The default label is "Launch at login", but it can be overridden for localization and other needs:

struct ContentView: View {
	var body: some View {
		LaunchAtLogin.Toggle {
			Text("Launch at login")
		}
	}
}

Alternatively, you can use LaunchAtLogin.observable as a binding with @ObservedObject:

import SwiftUI
import LaunchAtLogin

struct ContentView: View {
	@ObservedObject private var launchAtLogin = LaunchAtLogin.observable

	var body: some View {
		Toggle("Launch at login", isOn: $launchAtLogin.isEnabled)
	}
}

Combine

Just subscribe to LaunchAtLogin.publisher:

import Combine
import LaunchAtLogin

final class ViewModel {
	private var isLaunchAtLoginEnabled = LaunchAtLogin.isEnabled
	private var cancellables = Set<AnyCancellable>()

	func bind() {
		LaunchAtLogin
			.publisher
			.assign(to: \.isLaunchAtLoginEnabled, on: self)
			.store(in: &cancellables)
	}
}

Storyboards

Bind the control to the LaunchAtLogin.kvo exposed property:

import Cocoa
import LaunchAtLogin

final class ViewController: NSViewController {
	@objc dynamic var launchAtLogin = LaunchAtLogin.kvo
}

How does it work?

The package bundles the helper app needed to launch your app and copies it into your app at build time.

FAQ

I'm getting a “No such file or directory” error when archiving my app

Please ensure that the LaunchAtLogin run script phase is still below the “Embed Frameworks” phase. The order could have been accidentally changed.

The build error usually presents itself as:

cp: […]/Resources/LaunchAtLoginHelper.app: No such file or directory
rm: […]/Resources/copy-helper.sh: No such file or directory
Command PhaseScriptExecution failed with a nonzero exit code

The size of my app increased after adding LaunchAtLogin when using Carthage

The bundled launcher app is written in Swift and hence needs to embed the Swift runtime libraries. If your project targets macOS 10.14.4 or later, you can avoid embedding the Swift runtime libraries. First, open ./Carthage/Checkouts/LaunchAtLogin/LaunchAtLogin.xcodeproj and set the deployment target to the same as your app, and then run $ carthage build. You'll have to do this each time you update LaunchAtLogin.

This is not a problem when using Swift Package Manager.

My app doesn't show up in “System Preferences › Users & Groups › Login Items”

This is the expected behavior, unfortunately.

My app doesn't launch at login when testing

This is usually caused by having one or more older builds of your app laying around somewhere on the system, and macOS picking one of those instead, which doesn't have the launch helper, and thus fails to start.

Some things you can try:

  • Bump the version & build of your app so macOS is more likely to pick it.
  • Delete the DerivedData directory.
  • Ensure you don't have any other builds laying around somewhere.

Some helpful Stack Overflow answers:

Can you support CocoaPods?

CocoaPods used to be supported, but it did not work well and there was no easy way to fix it, so support was dropped. Even though you mainly use CocoaPods, you can still use Swift Package Manager just for this package without any problems.

I'm getting a 'SMCopyAllJobDictionaries' was deprecated in OS X 10.10 warning

Apple deprecated that API without providing an alternative. Apple engineers have stated that it's still the preferred API to use. I plan to use it as long as it's available. There are workarounds I can implement if Apple ever removes the API, so rest assured, this module will be made to work even then. If you want to see this resolved, submit a Feedback Assistant report with the following text. There's unfortunately still no way to suppress warnings in Swift.

I can't see the LaunchAtLogin.bundle in my debug build or I get a notarization error for developer ID distribution

As discussed here, this package tries to determine if you're making a release or debug build and clean up its install accordingly. If your debug build is missing the bundle or, conversely, your release build has the bundle and it causes a code signing error, that means this has failed.

The script's determination is based on the “Build Active Architecture Only” flag in build settings. If this is set to YES, then the script will package LaunchAtLogin for a debug build. You must set this flag to NO if you plan on distributing the build with codesigning.

Related

  • Defaults - Swifty and modern UserDefaults
  • KeyboardShortcuts - Add user-customizable global keyboard shortcuts to your macOS app
  • Regex - Swifty regular expressions
  • Preferences - Add a preferences window to your macOS app in minutes
  • DockProgress - Show progress in your app's Dock icon
  • create-dmg - Create a good-looking DMG for your macOS app in seconds
  • More…
Comments
  • App doesn't start on login

    App doesn't start on login

    I installed the framework using Carthage and set LaunchAtLogin.isEnabled = true on button click. But my app doesn't start at login. Is there something I am missing?

    opened by nadia-dev 20
  • script should handle archives as well as regular builds

    script should handle archives as well as regular builds

    opened by sweetleon 16
  • Support Swift Package Manager

    Support Swift Package Manager

    opened by benkoska 16
  • Swift Package Manager support

    Swift Package Manager support

    Fixes #4

    To test this Xcode 12 is required.

    I had to duplicate copy-helper.sh script due to big differences in paths. Maybe we can generalize logic in copy-helper.sh and create variants for Carthage and SwiftPM?


    IssueHunt Summary

    Referenced issues

    This pull request has been submitted to:


    opened by SergeyKuryanov 11
  • Specify Usage Instruction is only for Carthage

    Specify Usage Instruction is only for Carthage

    I was getting error #7 when I pasted the script path in Build Phase & I was using Podfile so as a Swift noob I installed the pod but also did this as shown in the README👇

    Add a new "Run Script Phase" below "Embed Frameworks" in "Build Phases" with the following: ./Carthage/Build/Mac/LaunchAtLogin.framework/Resources/copy-helper.sh

    It works fine without it so I think it should be specified it is only required for Carthage & not needed for CocoaPods as it may confuse beginners like me.

    opened by deadcoder0904 10
  • Helper needs com.apple.security.automation.apple-events entitlement

    Helper needs com.apple.security.automation.apple-events entitlement

    Trying the LaunchAtLogin helper in another app of mine today. Got this when I triggered the setting:

    Prompting policy for hardened runtime; service: kTCCServiceAppleEvents requires entitlement com.apple.security.automation.apple-events but it is missing for ACC:{ID: de.christiantietze.WorkBreak-LaunchAtLoginHelper, PID[2079], auid: 501, euid: 501, binary path: '/Applications/Move!.app/Contents/Library/LoginItems/LaunchAtLoginHelper.app/Contents/MacOS/LaunchAtLoginHelper'}, REQ:{ID: com.apple.appleeventsd, PID[51], auid: 55, euid: 55, binary path: '/System/Library/CoreServices/appleeventsd'}

    Looks like the helper needs com.apple.security.automation.apple-events hardened runtime resource access.

    opened by DivineDominion 8
  • Cocoapods: Could not locate login item

    Cocoapods: Could not locate login item

    Edited with new information:

    When you install the cocoapod, this module doesn't actually work. But it works when you use Carthage.

    Original bug:

    First off, thanks for kicking off a project like this. It looks really helpful and seems super easy to use. But when I integrate it. And try to toggle the LaunchAtLogin.isEnabled, it just shows me this as an error.

    2018-12-24 01:19:21.312633-0800 YoctoChat[7479:335659] Could not locate login item renebrandel.YoctoChat-LaunchAtLoginHelper in the caller's bundle
    2018-12-24 01:19:21.313307-0800 YoctoChat[7479:335659] Could not enable login item: renebrandel.YoctoChat-LaunchAtLoginHelper: 3: No such process
    2018-12-24 01:19:21.325436-0800 YoctoChat[7479:335659] Could not enable login item: renebrandel.YoctoChat-LaunchAtLoginHelper: 3: No such process
    

    -Rene I've enabled codesigning and tried other solution of resolved issues but no luck so far. Any idea on how to debug this?

    opened by renebrandel 6
  • Codesign question

    Codesign question

    Thanks for project, it looks very simple but it simply just doesn't work for me. How can I debug it? After setting LaunchAtLogin.isEnabled = true it resets to false. App exported, signed with Developer ID and placed in /Applications.

    The most unknown part for me - how to codesign helper on export? Do I need to create separate app id and provision profile for it?

    I'm exporting with "Developer ID" signing to test it (only main app signed), I haven't pushed it to App Store yet. Tried exporting "for App Store" - can't even continue without creating provisioning profile for helper app.

    opened by ealeksandrov 6
  • Where to add script?

    Where to add script?

    Hi! After nearly one year and I found that README.md has been updated:

    Add a new “Run Script Phase” below (not into) “Copy Bundle Resources” in “Build Phases” with the following

    Bear with me but I'm still confused about how can I add this script? 😓

    Here's what I've done:

    image

    Don't know if I'm doing this right... Does this mean that I can continue to use this framework or am I missing something? Thanks for your patience!

    opened by RoyRao2333 5
  • Apple notarization fails

    Apple notarization fails

    I've just switched from Carthage to SPM and I'm using v4.0.0

    Everything works fine except Apple won't notarize the app, throwing a "Package Invalid" error with the following messages:

    • The binary is not signed with a valid developer id certificate
    • The signature does not include a secure timestamp
    • The executable requests the com.apple.security.get-task-allow entitlement

    macOS version: 10.15.7 Xcode version: 12.0.1

    More info about affected files:

    
    - The binary is not signed with a valid developer id certificate
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper.zip/LaunchAtLoginHelper.app/Contents/MacOS/LaunchAtLoginHelper
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/MacOS/LaunchAtLoginHelper
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftAppKit.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftCoreImage.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftObjectiveC.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftXPC.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftCore.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftCoreGraphics.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftMetal.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftCoreData.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftDispatch.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftos.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftCoreFoundation.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftDarwin.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftQuartzCore.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftIOKit.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftFoundation.dylib
    
    - The signature does not include a secure timestamp
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper.zip/LaunchAtLoginHelper.app/Contents/MacOS/LaunchAtLoginHelper
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/MacOS/LaunchAtLoginHelper
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftAppKit.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftCoreImage.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftObjectiveC.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftXPC.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftCore.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftCoreGraphics.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftMetal.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftCoreData.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftDispatch.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftos.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftCoreFoundation.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftDarwin.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftQuartzCore.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftIOKit.dylib
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/Frameworks/libswiftFoundation.dylib
    
    - The executable requests the com.apple.security.get-task-allow entitlement
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper.zip/LaunchAtLoginHelper.app/Contents/MacOS/LaunchAtLoginHelper
      - MyApp.zip/MyApp.app/Contents/Resources/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/LaunchAtLoginHelper-with-runtime.zip/LaunchAtLoginHelper.app/Contents/MacOS/LaunchAtLoginHelper
    
    
    opened by rameerez 5
  • code object is not signed at all

    code object is not signed at all

    Hello,

    I'm encountering some problems with LaunchAtLogin that I can't figure out by myself: I've integrated the framework using Carthage, added the script, and now whenever I try to compile I get this error:

    code object is not signed at all
    In subcomponent: Contents/Library/LoginItems/LaunchAtLoginHelper.app
    

    Any ideas what I could try to solve this issue?

    opened by frogg 5
  • App not launching at login

    App not launching at login

    LaunchAtLogin was not working on the app I am working on so I decided to create a new app just with the package to check if it would work. I created a new macOS app (without storyboard) and followed the steps on the README and it's not working. Is there anything else I should try? I've already tried to delete Derived Data, clean build but it still not working.

    Any idea how to solve it? Is there any info/log I can send to help to debug this issue?

    Screen Shot 2022-10-13 at 13 03 36 Screen Shot 2022-10-13 at 13 04 12

    opened by fredmurakawa 1
  • Launch at Login Toggle not working

    Launch at Login Toggle not working

    The launch at login toggle does not work when I package the app for distribution, however it does work when I run the app from XCode. Is there any reason for this? Is there any fix?

    opened by ghost 2
  • LaunchAtLogin_LaunchAtLogin.bundle being copied back into bundle *after* being removed

    LaunchAtLogin_LaunchAtLogin.bundle being copied back into bundle *after* being removed

    The custom build script removes this file, then xcodebuild separated re-adds this bundle afterwards for production builds.

    I'm not sure why this bundle is added to the main app bundle to begin with. Any solutions for this?

    opened by lmcd 2
  • App won't start at login

    App won't start at login

    Created a new project with a fresh bundle id to avoid zombie instances of the app.

    This is my code:

    @IBAction func onBtn(_ sender: NSButton) {
            LaunchAtLogin.isEnabled = true
        }    
        
        @IBAction func offBtn(_ sender: NSButton) {
            LaunchAtLogin.isEnabled = false
        }
        
        override func viewDidLoad() {
            super.viewDidLoad()
            if(LaunchAtLogin.isEnabled){
                status.stringValue = "ON"
            }
            else
            {
                status.stringValue = "OFF"
            }        
        }
    

    I've run it in debugging mode. I can see that isEnabled returns true even after restarting the app. Also, running /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -dump will include the fresh bundle id but yet when restarting my machine, the app won't launch.

    How else can I debug this?

    Edit: Seems like the issue is when compiled on Xcode Version 13.0 beta 5

    opened by Shasoosh 4
  • ERROR ITMS-90334:

    ERROR ITMS-90334: "Invalid Code Signature Identifier."

    While uploading an app to iTunes Connect I receive the following error message within Xcode:

    ERROR ITMS-90334: Invalid Code Signature Identifier. The identifier "com.sindresorhus.LaunchAtLoginHelper" in your code signature for "LaunchAtLoginHelper" must match its Bundle Identifier "io.frogg.my.app"

    Screenshot 2020-08-28 at 23 55 40

    Any idea what's going on here?

    opened by frogg 12
  • Indicate whether the app was launched at login

    Indicate whether the app was launched at login

    Sometimes you would want different behavior if the app was launched at login vs. normally. For example, you want a window to show when launched normally, but not when launched at login.

    We could add a property LaunchAtLogin.wasLaunchedAtLogin for this.

    The helper app will have to somehow pass a message to the main app, which we'll read and use in the .wasLaunchedAtLogin property.

    One possible solution here: https://blog.timschroeder.net/2014/01/25/detecting-launch-at-login-revisited/ But I was hoping for a simpler solution.


    I have tried checking keySenderPIDAttr at applicationDidFinishLaunching, but it just pointed at the main app.

    enhancement help wanted 
    opened by sindresorhus 8
Releases(v5.0.0)
  • v5.0.0(Nov 13, 2022)

    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:

    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 code(tar.gz)
    Source code(zip)
  • v4.2.0(Oct 9, 2021)

    • Silence SMCopyAllJobDictionaries deprecation warning https://github.com/sindresorhus/LaunchAtLogin/commit/b35bfbde576b39a18d473da3b032e45f52c21a16

    https://github.com/sindresorhus/LaunchAtLogin/compare/v4.1.0...v4.2.0

    Source code(tar.gz)
    Source code(zip)
  • v4.1.0(Mar 20, 2021)

    • Add native Apple Silicon support to the helper app https://github.com/sindresorhus/LaunchAtLogin/commit/f1cc3b8dd52f3eab1a87e2be5f4cb3b229e47d73
    • Add ITSAppUsesNonExemptEncryption to the helper app https://github.com/sindresorhus/LaunchAtLogin/commit/b068272af8420fc0a27ecfb7b54d900552359102
    • Fix notarization issues with build configs not named "Release" (#57) https://github.com/sindresorhus/LaunchAtLogin/commit/2badfdd7df05490b9486e9f99eccc4713cd04822

    https://github.com/sindresorhus/LaunchAtLogin/compare/v4.0.0...v4.1.0

    Source code(tar.gz)
    Source code(zip)
  • v4.0.0(Sep 17, 2020)

    Breaking

    • Requires Xcode 12 to build.

    Improvements

    • Swift Package Manager support! https://github.com/sindresorhus/LaunchAtLogin/commit/060284a1994934c5f258ce5c0c9202d63eea8c3a This is now the recommended way to install LaunchAtLogin. Carthage support will be removed at some point in the future.
    • A SwiftUI component for toggling "launch at login" is now bundled. https://github.com/sindresorhus/LaunchAtLogin/commit/f7b255bc96965a178dc8f1073058a037b35d38fd It could not be easier to add support for "launch at login" in your app.
    • We also added built-in conveniences for @ObservedObject, Combine, and Storyboards (KVO). https://github.com/sindresorhus/LaunchAtLogin/commit/f7b255bc96965a178dc8f1073058a037b35d38fd

    Huge thanks to @SergeyKuryanov for implementing a lot of the things in this release.

    Source code(tar.gz)
    Source code(zip)
  • v3.0.2(Jul 25, 2020)

  • v3.0.1(Jun 9, 2020)

    • Don’t inherit entitlements from the main app in the helper app (#38) The helper app only needs to be sandboxed. Previously, it incorrectly inherited the sandbox entitlements of the parent app.

    https://github.com/sindresorhus/LaunchAtLogin/compare/v3.0.0...v3.0.1

    Source code(tar.gz)
    Source code(zip)
  • v3.0.0(Jan 21, 2020)

    Breaking

    • Require Swift 5 https://github.com/sindresorhus/LaunchAtLogin/commit/a3e48661e30fa2419074b22d0075fc4979b8f548
    • Drop support for CocoaPods https://github.com/sindresorhus/LaunchAtLogin/commit/db82bf69ea827d5b763603678b188729d8b60d8a It didn't work correctly anyway.

    Enhancements

    • Set signing to local & "None" (#28) https://github.com/sindresorhus/LaunchAtLogin/commit/ff900e85312198f3bd0b42a4b8b43969e4215ae1

    https://github.com/sindresorhus/LaunchAtLogin/compare/v2.5.0...v3.0.0

    Source code(tar.gz)
    Source code(zip)
Owner
Sindre Sorhus
Full-Time Open-Sourcerer. Wants more empathy & kindness in open source. Focuses on Swift & JavaScript. Makes macOS apps, CLI tools, npm packages. Likes unicorns
Sindre Sorhus
A way to easily add Cocoapod licenses and App Version to your iOS App using the Settings Bundle

EasyAbout Requirements: cocoapods version 1.4.0 or above. Why you should use Well, it is always nice to give credit to the ones who helped you ?? Bonu

João Mourato 54 Apr 6, 2022
Add publisher to reachability

ReachabilityCombine Add publisher to Reachability for convenience. usage

null 1 Oct 25, 2021
Versions tracker for your iOS, macOS, and tvOS app

VersionTrackerSwift VersionTrackerSwift is a versions / builds tracker to know which version has been installed by a user. Usage In your ApplicationDe

Tom Baranes 82 Oct 5, 2022
ALO sync allows you to sync resources form an ALO endpoint to your macOS file system.

ALO sync allows you to sync resources form an ALO endpoint to your macOS file system. Prerequisites macOS 11 No support for search* No suppor

Lawrence Bensaid 2 Jan 22, 2022
A cross-platform library of Swift utils to ease your iOS | macOS | watchOS | tvOS and Linux development.

Mechanica A library of Swift utils to ease your iOS, macOS, watchOS, tvOS and Linux development. Requirements Documentation Installation License Contr

Alessandro 28 Aug 28, 2022
Automatically set your keyboard's backlight based on your Mac's ambient light sensor.

QMK Ambient Backlight Automatically set your keyboard's backlight based on your Mac's ambient light sensor. Compatibility macOS Big Sur or later, a Ma

Karl Shea 29 Aug 6, 2022
LibAuthentication will simplify your code when if you want to use FaceID/TouchID in your tweaks.

LibAuthentication will simplify your code when if you want to use FaceID/TouchID in your tweaks.

Maximehip 6 Oct 3, 2022
RNH Tracker is a GPS logger for iOS (iPhone, iPad, iPod) Track your location and send your logs to RNH Regatta :-)

RNH Tracker for iOS + WatchOS RNH Tracker is a GPS logger for iOS (iPhone, iPad, iPod) with offline map cache support. Track your location, add waypoi

Ed Cafferata 0 Jan 23, 2022
Record your position and export your trip in GPX with GPS Stone on iOS.

GPS Stone Register your trips and export them as GPX files. Notes We currently have included a UIRequiredDeviceCapabilities with a location-services v

Frost Land 11 Sep 24, 2022
A utility that reminds your iPhone app's users to review the app written in pure Swift.

SwiftRater SwiftRater is a class that you can drop into any iPhone app that will help remind your users to review your app on the App Store/in your ap

Takeshi Fujiki 289 Dec 12, 2022
Small app that checks focus status under macOS 12

infocus What Small app for Mac Admins that checks focus status under macOS 11 and 12 and can be used to add Do Not Disturb support to management scrip

Bart Reardon 12 Nov 8, 2022
Generate a privacy policy for your iOS app

PrivacyFlash Pro To easily run PrivacyFlash Pro get the latest packaged release. Learn more about PrivacyFlash Pro in our research paper. PrivacyFlash

privacy-tech-lab 141 Dec 22, 2022
Tweak your iOS app without recompiling!

SwiftTweaks Adjust your iOS app on the fly without waiting to re-compile! Your users won’t see your animation study, Sketch comps, or prototypes. What

Khan Academy 1.4k Dec 28, 2022
WhatsNewKit enables you to easily showcase your awesome new app features.

WhatsNewKit enables you to easily showcase your awesome new app features. It's designed from the ground up to be fully customized to your needs. Featu

Sven Tiigi 2.8k Jan 3, 2023
Checks if there is a newer version of your app in the AppStore and alerts the user to update.

YiAppUpdater Checks if there is a newer version of your app in the AppStore and alerts the user to update. Installation YiAppUpdater is available thro

coderyi 4 Mar 17, 2022
An app that converts the temperature in Fahrenheit your input, and then changes to Celsius.

Swift Temperature Converter An app that converts the temperature in Fahrenheit your input, and then changes to Celsius. Things you need to do ?? clone

Tsuen Hsueh 1 Aug 16, 2022
Tweak your iOS app without recompiling!

SwiftTweaks Adjust your iOS app on the fly without waiting to re-compile! Your users won’t see your animation study, Sketch comps, or prototypes. What

Khan Academy 1.4k Dec 28, 2022
A framework to provide logic designed to prompt users at the ideal moment for a review of your app/software

ReviewKit ReviewKit is a Swift package/framework that provides logic designed to prompt users at the ideal moment for a review of your app. At a basic

Simon Mitchell 25 Jun 7, 2022
CipherCode - iOS App to decode your secret message

CipherCode IOS App to decode/encode your secret message App App consist of welco

Doston Rustamov 0 Jan 15, 2022