Skip to content

Fix crash on launch on macOS 14 (Sonoma) - #90

Merged
devxoul merged 1 commit into
mainfrom
fix/crash-on-launch-macos14
Feb 22, 2026
Merged

Fix crash on launch on macOS 14 (Sonoma)#90
devxoul merged 1 commit into
mainfrom
fix/crash-on-launch-macos14

Conversation

@devxoul

@devxoul devxoul commented Feb 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fix launch crash (SIGABRT in CGSConnectionByID) affecting all macOS 14.x (Sonoma) users.

Problem

The app crashes immediately on launch on macOS 14.x — the status bar icon never appears and the app silently terminates. Confirmed by multiple crash reports from App Store Connect on macOS 14.6.1, 14.8.2, and 14.8.3.

Crash stack trace:

SIGABRT → __assert_rtn → CGSConnectionByID
  ← SLSRegisterConnectionNotifyProc
  ← +[NSCGSStatusItem addNavigationChangedNotificationHandler:]
  ← -[NSStatusItem _initWithStatusBar:length:priority:systemInsertOrder:]
  ← AppDelegate.init() (AppDelegate.swift:8)
  ← SwiftUI: FallbackDelegateBox.delegate.getter
  ← SwiftUI: runApp(_:)

Root Cause

NSStatusBar.system.statusItem(withLength:) was called as a property initializer in AppDelegate, which runs during init(). On macOS 14.x, SwiftUI creates the @NSApplicationDelegateAdaptor before the window server (CGS) connection is established. NSStatusItem initialization requires a valid CGS connection to register notification handlers, causing an assertion failure → abort().

On macOS 26, SwiftUI establishes the CGS connection earlier so this happened to work — but it was never safe to call during init().

Fix

Defer NSStatusItem creation from the property initializer to applicationDidFinishLaunching, where the CGS connection is guaranteed to be ready.

- private let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
+ private var statusItem: NSStatusItem!
  func applicationDidFinishLaunching(_: Notification) {
    AppDelegate.shared = self
+   self.statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
    self.setupStatusItem()

Summary by cubic

Fixes a launch crash on macOS 14 (Sonoma) by creating the status bar item after the app finishes launching. Sonoma users can now start the app and see the menu bar icon.

  • Bug Fixes
    • Defer NSStatusItem creation from a property initializer to applicationDidFinishLaunching to wait for a valid CGS connection and avoid SIGABRT in CGSConnectionByID.

Written for commit a10ae9f. Summary will update on new commits.

Defer NSStatusItem creation from property initializer to applicationDidFinishLaunching. On macOS 14, SwiftUI creates the @NSApplicationDelegateAdaptor before the window server (CGS) connection is established, causing an assertion failure in CGSConnectionByID when NSStatusBar.system.statusItem is called during AppDelegate.init().

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 1 file

@devxoul
devxoul merged commit 661d2a1 into main Feb 22, 2026
2 checks passed
@devxoul
devxoul deleted the fix/crash-on-launch-macos14 branch February 22, 2026 13:49
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