Skip to content

Feature/auto start#5

Merged
YONN2222 merged 3 commits intomainfrom
feature/auto-start
Oct 11, 2025
Merged

Feature/auto start#5
YONN2222 merged 3 commits intomainfrom
feature/auto-start

Conversation

@YONN2222
Copy link
Owner

This pull request introduces improvements to the auto-launch functionality and updates project metadata for the cmdX macOS 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:

  • The app now attempts to enable auto-launch on first run, storing the user's preference in UserDefaults and allowing them to disable it later. This is handled in the AppDelegate within cmdX/cmdXApp.swift.
  • Added a fallback method using a LaunchAgent plist for enabling auto-launch on older macOS versions or when app signing is unavailable. This includes new helper methods in cmdX/cmdXApp.swift.
  • The user's auto-launch preference is now stored and respected in UserDefaults, with logic to initialize and update the toggle accordingly in cmdX/ContentView.swift. [1] [2]

Project configuration updates:

  • Updated the marketing version from 1.1 to 1.2 and set the application category to "productivity" in the project file cmdX.xcodeproj/project.pbxproj. [1] [2]
  • Explicitly set the code signing identity to "Apple Development" for macOS targets in the project file. [1] [2]

Dependency management:

  • Added a missing import for ServiceManagement in cmdX/cmdXApp.swift to support auto-launch registration.

Copilot AI review requested due to automatic review settings October 11, 2025 16:49
@YONN2222 YONN2222 merged commit 0400acb into main Oct 11, 2025
1 check passed
@YONN2222 YONN2222 deleted the feature/auto-start branch October 11, 2025 16:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
Bundle.main.bundleIdentifier ?? "com.yourcompany.commandX"
Bundle.main.bundleIdentifier ?? "com.yonn2222.cmdX"

Copilot uses AI. Check for mistakes.
Comment on lines +152 to +169
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)
}
}
Copy link

Copilot AI Oct 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is duplicated between AppDelegate and ContentView. Consider extracting this functionality into a shared utility class or helper to avoid code duplication.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant