LaunchAtLogin icon indicating copy to clipboard operation
LaunchAtLogin copied to clipboard

App won't start at login

Open Shasoosh opened this issue 4 years ago • 5 comments

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

Shasoosh avatar Sep 13 '21 07:09 Shasoosh

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

  • Fresh app
  • cleared Derived Data and Bin before trying
  • /System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill

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

flymg avatar Jan 02 '22 13:01 flymg

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

Shasoosh avatar Jan 03 '22 01:01 Shasoosh

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.

flymg avatar Jan 03 '22 07:01 flymg

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

ukushu avatar Dec 20 '22 03:12 ukushu

Same problem with me . Any ideas?

bingolead-stack avatar Apr 18 '24 20:04 bingolead-stack