33

GitHub - sindresorhus/LaunchAtLogin: Add "Launch at Login" functionali...

 5 years ago
source link: https://github.com/sindresorhus/LaunchAtLogin
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

readme.md

LaunchAtLogin

Add "Launch at Login" functionality to your sandboxed macOS app in seconds

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

It's App Store compatible and used in my Lungo and Battery Indicator app.

You might also find my create-dmg project useful.

Requirements

  • macOS 10.12+
  • Xcode 10+
  • Swift 4.2+

Install

Carthage

github "sindresorhus/LaunchAtLogin"

CocoaPods

pod 'LaunchAtLogin'
68747470733a2f2f63352e70617472656f6e2e636f6d2f65787465726e616c2f6c6f676f2f6265636f6d655f615f706174726f6e5f627574746f6e4032782e706e67

Usage

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

Carthage:

./Carthage/Build/Mac/LaunchAtLogin.framework/Resources/copy-helper.sh

CocoaPods:

./Pods/LaunchAtLogin/LaunchAtLogin/copy-helper.sh

Use it in your app:

import LaunchAtLogin

print(LaunchAtLogin.isEnabled)
//=> false

LaunchAtLogin.isEnabled = true

print(LaunchAtLogin.isEnabled)
//=> true

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.

How does it work?

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

Related

License

MIT © Sindre Sorhus


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK