Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the auto-launch functionality for the cmdX macOS app by implementing automatic registration on first run, storing user preferences persistently, and providing fallback mechanisms for older macOS versions. The changes also update project metadata to version 1.2 with proper code signing configuration.
- Automatic auto-launch registration on first run with user preference persistence
- Fallback LaunchAgent implementation for older macOS versions or unsigned apps
- Project configuration updates including version bump and code signing setup
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| cmdX/cmdXApp.swift | Added ServiceManagement import and auto-launch registration logic in AppDelegate with LaunchAgent fallback methods |
| cmdX/ContentView.swift | Updated toggle behavior to persist user preferences and initialize from stored values |
| cmdX.xcodeproj/project.pbxproj | Bumped version to 1.2, added productivity category, and configured Apple Development code signing |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
|
||
| // MARK: - Launch at Login via LaunchAgent (fallback for older macOS or unsigned app) | ||
| private var bundleIdentifier: String { | ||
| Bundle.main.bundleIdentifier ?? "com.yourcompany.commandX" |
There was a problem hiding this comment.
The fallback bundle identifier 'com.yourcompany.commandX' appears to be a placeholder and doesn't match the actual bundle identifier 'com.yonn2222.cmdX' used in the project configuration.
| Bundle.main.bundleIdentifier ?? "com.yourcompany.commandX" | |
| Bundle.main.bundleIdentifier ?? "com.yonn2222.cmdX" |
| private func setLaunchAtLogin(enabled: Bool) { | ||
| let fm = FileManager.default | ||
| let plistURL = launchAgentPlistPath() | ||
| if enabled { | ||
| let executable = (Bundle.main.infoDictionary?["CFBundleExecutable"] as? String) ?? "commandX" | ||
| let exePath = Bundle.main.bundlePath + "/Contents/MacOS/" + executable | ||
| let dict: [String: Any] = [ | ||
| "Label": bundleIdentifier, | ||
| "ProgramArguments": [exePath], | ||
| "RunAtLoad": true | ||
| ] | ||
| if let data = try? PropertyListSerialization.data(fromPropertyList: dict, format: .xml, options: 0) { | ||
| try? data.write(to: plistURL) | ||
| } | ||
| } else { | ||
| try? fm.removeItem(at: plistURL) | ||
| } | ||
| } |
There was a problem hiding this comment.
This method is duplicated between AppDelegate and ContentView. Consider extracting this functionality into a shared utility class or helper to avoid code duplication.
This pull request introduces improvements to the auto-launch functionality and updates project metadata for the
cmdXmacOS app. The main changes include defaulting the app to auto-launch on first run, persisting the user's auto-launch preference, and adding a fallback mechanism for older macOS versions or unsigned apps. Additionally, project configuration updates reflect a new app version and proper code signing.Auto-launch functionality improvements:
UserDefaultsand allowing them to disable it later. This is handled in theAppDelegatewithincmdX/cmdXApp.swift.cmdX/cmdXApp.swift.UserDefaults, with logic to initialize and update the toggle accordingly incmdX/ContentView.swift. [1] [2]Project configuration updates:
cmdX.xcodeproj/project.pbxproj. [1] [2]Dependency management:
ServiceManagementincmdX/cmdXApp.swiftto support auto-launch registration.