Permalink
Browse files

fix auto launch, signing

  • Loading branch information...
1 parent f8e2a67 commit 4701936541f62b6921ae531499f834982681ae18 Chris Smith committed Jan 1, 2017
Showing with 58 additions and 5 deletions.
  1. +2 −1 .gitignore
  2. +19 −2 Hint.xcodeproj/project.pbxproj
  3. +28 −0 Hint/AppDelegate.swift
  4. +7 −0 Hint/Base.lproj/MainMenu.xib
  5. +2 −2 HintLauncher/AppDelegate.swift
View
@@ -66,4 +66,5 @@ fastlane/test_output
# Project
-**/project.xcworkspace
+**/project.xcworkspace
+**/.DS_Store
@@ -14,6 +14,7 @@
4BA9F3BE1E18B34D007D1506 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4BA9F3BC1E18B34D007D1506 /* MainMenu.xib */; };
4BA9F3C51E18B4C1007D1506 /* HintLauncher.app in CopyFiles */ = {isa = PBXBuildFile; fileRef = 4BA9F3B61E18B34D007D1506 /* HintLauncher.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
4BA9F3C81E18B540007D1506 /* ServiceManagement.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4BA9F3C71E18B540007D1506 /* ServiceManagement.framework */; };
+ 4BA9F3CB1E18D162007D1506 /* Scheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BA9F3CA1E18D162007D1506 /* Scheduler.swift */; };
4BD7DC531E1383E500237385 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BD7DC521E1383E500237385 /* AppDelegate.swift */; };
4BD7DC581E1383E500237385 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4BD7DC561E1383E500237385 /* MainMenu.xib */; };
4BD7DC631E1383E500237385 /* HintTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BD7DC621E1383E500237385 /* HintTests.swift */; };
@@ -58,6 +59,7 @@
4BA9F3C31E18B3A2007D1506 /* HintLauncher.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = HintLauncher.entitlements; sourceTree = "<group>"; };
4BA9F3C71E18B540007D1506 /* ServiceManagement.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ServiceManagement.framework; path = System/Library/Frameworks/ServiceManagement.framework; sourceTree = SDKROOT; };
4BA9F3C91E18C296007D1506 /* Hint.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Hint.entitlements; sourceTree = "<group>"; };
+ 4BA9F3CA1E18D162007D1506 /* Scheduler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Scheduler.swift; sourceTree = "<group>"; };
4BD7DC4F1E1383E500237385 /* Hint.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Hint.app; sourceTree = BUILT_PRODUCTS_DIR; };
4BD7DC521E1383E500237385 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
4BD7DC571E1383E500237385 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = "<group>"; };
@@ -153,6 +155,7 @@
4BD7DC741E15B85E00237385 /* TextSource.swift */,
4BD7DC761E15BAE600237385 /* Util.swift */,
4BD7DC561E1383E500237385 /* MainMenu.xib */,
+ 4BA9F3CA1E18D162007D1506 /* Scheduler.swift */,
);
path = Hint;
sourceTree = "<group>";
@@ -242,6 +245,7 @@
TargetAttributes = {
4BA9F3B51E18B34D007D1506 = {
CreatedOnToolsVersion = 8.2.1;
+ DevelopmentTeam = TP9ZH34C5J;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.Sandbox = {
@@ -251,6 +255,7 @@
};
4BD7DC4E1E1383E500237385 = {
CreatedOnToolsVersion = 8.2.1;
+ DevelopmentTeam = TP9ZH34C5J;
ProvisioningStyle = Automatic;
SystemCapabilities = {
com.apple.Sandbox = {
@@ -328,6 +333,7 @@
buildActionMask = 2147483647;
files = (
4BA9F3AF1E188A06007D1506 /* Constants.swift in Sources */,
+ 4BA9F3CB1E18D162007D1506 /* Scheduler.swift in Sources */,
4BD7DC531E1383E500237385 /* AppDelegate.swift in Sources */,
4BD7DC731E15B82200237385 /* Notifier.swift in Sources */,
4BD7DC751E15B85E00237385 /* TextSource.swift in Sources */,
@@ -379,10 +385,12 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = HintLauncher/HintLauncher.entitlements;
+ CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
+ DEVELOPMENT_TEAM = TP9ZH34C5J;
INFOPLIST_FILE = HintLauncher/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
- MACOSX_DEPLOYMENT_TARGET = 10.12;
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = com.crsmithdev.HintLauncher;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
@@ -395,10 +403,12 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = HintLauncher/HintLauncher.entitlements;
+ CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
+ DEVELOPMENT_TEAM = TP9ZH34C5J;
INFOPLIST_FILE = HintLauncher/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
- MACOSX_DEPLOYMENT_TARGET = 10.12;
+ MACOSX_DEPLOYMENT_TARGET = 10.11;
PRODUCT_BUNDLE_IDENTIFIER = com.crsmithdev.HintLauncher;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
@@ -502,12 +512,16 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = NO;
CODE_SIGN_ENTITLEMENTS = Hint/Hint.entitlements;
+ CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
+ DEVELOPMENT_TEAM = TP9ZH34C5J;
INFOPLIST_FILE = Hint/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
OTHER_SWIFT_FLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.crsmithdev.Hint;
PRODUCT_NAME = "$(TARGET_NAME)";
+ PROVISIONING_PROFILE = "";
+ PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 3.0;
};
name = Debug;
@@ -518,7 +532,9 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = NO;
CODE_SIGN_ENTITLEMENTS = Hint/Hint.entitlements;
+ CODE_SIGN_IDENTITY = "Mac Developer";
COMBINE_HIDPI_IMAGES = YES;
+ DEVELOPMENT_TEAM = TP9ZH34C5J;
INFOPLIST_FILE = Hint/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.crsmithdev.Hint;
@@ -567,6 +583,7 @@
4BA9F3C21E18B34D007D1506 /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
4BD7DC4A1E1383E500237385 /* Build configuration list for PBXProject "Hint" */ = {
isa = XCConfigurationList;
View
@@ -8,6 +8,7 @@
import Foundation
import Cocoa
+import ServiceManagement
enum NotificationText: String {
case hints = "Hints"
@@ -36,6 +37,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let statusItem = NSStatusBar.system().statusItem(withLength: NSSquareStatusItemLength)
var textSource: TextSource!
+ var autoLaunch: Bool = false
var notificationText = NotificationText.hints
var notificationSound = NotificationSound.silent
@@ -88,6 +90,27 @@ class AppDelegate: NSObject, NSApplicationDelegate {
loadText(text: notificationTextOptions[sender.tag]!)
}
+ @IBAction func actionChangeAutoLaunch(_ sender: NSMenuItem) {
+
+ autoLaunch = !autoLaunch
+
+ let appBundleIdentifier = "com.crsmithdev.HintLauncher"
+ var helperURL = Bundle.main.bundleURL
+ helperURL.appendPathComponent("Contents/Library/LoginItems/HintLauncher.app")
+ let ret = LSRegisterURL(helperURL as CFURL, true)
+
+ if SMLoginItemSetEnabled(appBundleIdentifier as CFString, autoLaunch) {
+ if autoLaunch {
+ NSLog("Successfully add login item.")
+ } else {
+ NSLog("Successfully remove login item.")
+ }
+
+ } else {
+ NSLog("Failed to add login item.")
+ }
+ }
+
@IBAction func actionQuit(_ sender: AnyObject) {
NSApplication.shared().terminate(self)
}
@@ -115,6 +138,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
return paused
}
+ if menuItem.action == #selector(self.actionChangeAutoLaunch) {
+ menuItem.state = autoLaunch ? 1 : 0
+ return true
+ }
+
return true
}
@@ -185,6 +185,13 @@
</menu>
</menuItem>
<menuItem isSeparatorItem="YES" id="2gG-mi-hjj"/>
+ <menuItem title="Auto Launch" id="FPD-xc-baW">
+ <modifierMask key="keyEquivalentModifierMask"/>
+ <connections>
+ <action selector="actionChangeAutoLaunch:" target="Voe-Tx-rLC" id="74W-vT-A2V"/>
+ </connections>
+ </menuItem>
+ <menuItem isSeparatorItem="YES" id="2jH-Qm-Bxv"/>
<menuItem title="Quit" id="8zN-TD-C5d">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
@@ -17,8 +17,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let launcherPath = Bundle.main.bundlePath as NSString
var components = launcherPath.pathComponents
components.removeLast()
- components.append("Hint.app")
- components.append("Contents")
+ components.removeLast()
+ components.removeLast()
components.append("MacOS")
components.append("Hint")

0 comments on commit 4701936

Please sign in to comment.