Coder Social home page Coder Social logo

mayoff / launchatlogin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sindresorhus/launchatlogin

0.0 1.0 0.0 47 KB

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

License: MIT License

Objective-C 6.00% Swift 57.78% Shell 36.22%

launchatlogin's Introduction

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 11+
  • Swift 5+

Install

Carthage

github "sindresorhus/LaunchAtLogin"

Usage

Add a new "Run Script Phase" below "Embed Frameworks" in "Build Phases" with the following:

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

Use it in your app:

import LaunchAtLogin

print(LaunchAtLogin.isEnabled)
//=> false

LaunchAtLogin.isEnabled = true

print(LaunchAtLogin.isEnabled)
//=> true

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.

How does it work?

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

FAQ

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 Carthage 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.

Related

  • Defaults - Swifty and modern UserDefaults
  • 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…

launchatlogin's People

Contributors

boyvanamstel avatar divinedominion avatar nicoeg avatar sindresorhus avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.