sindresorhus / LaunchAtLogin-Legacy

Add “Launch at Login” functionality to your macOS app in seconds
MIT License
1.55k stars 122 forks source link

App won't start at login #65

Open Shasoosh opened 2 years ago

Shasoosh commented 2 years ago

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

flymg commented 2 years ago

I can confirm that i experience the same. The Package seems fine, also did the following:

I also build another fresh app and added the workflow with all settings myself which is also not working with the same result.

Simply no launch after login

XCode 13.2 on BigSur 11.6.1

Shasoosh commented 2 years ago

This is keeping me on Xcode 12.4. Any update on this?

flymg commented 2 years ago

I was able to get the mechanism to work yesterday after upgrading to macOS 11.6.2

I discovered, that SMLoginItemSetEnabled did not triggered to update /private/var/db/com.apple.xpc.launchd/loginitems.501.plist to make the corresponding entries for App and LauncherApp. It also did not check the return values of SMLoginItemSetEnabled, which i do now. After upgrade of macOS the entry was written, and AutoLaunch works.

ukushu commented 1 year ago

MacOs: 13.1 (22C65) Xcode: 14.2 (14C18)

App added to startup applications of MacOS

введите сюда описание изображения

but app won't start after computer restart.

App installed via TestFlight. This may be important --

tonybingo-stack commented 4 months ago

Same problem with me . Any ideas?