Skip to content

Conversation

@vksvicky
Copy link

@vksvicky vksvicky commented Dec 2, 2025

This PR fixes multiple issues related to macOS 14 compatibility, compiler warnings, and a memory leak.

Description

  • ✅ Updated macOS deployment target from 13.0 to 14.0
  • ✅ Fixed 80+ SwiftUI onChange(of:perform:) deprecation warnings
  • ✅ Fixed unreachable code warning in LSPService.swift
  • ✅ Added required app entitlements for file access (fixes crash on file dialogs)
  • ✅ Fixed memory leak in CurrentUser.getCurrentUser()

Related Issues

#2133

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • [] My changes are all related to the related issue above
  • [] I documented my code

Screenshots

Resolves build errors with test frameworks (XCTest, Testing) that
require macOS 14.0+. This fixes the following linker warnings:
- Building for macOS-13.0 but linking with XCTest built for 14.0
- Building for macOS-13.0 but linking with libXCTestSwiftSupport built for 14.0
- Building for macOS-13.0 but linking with Testing framework built for 14.0
- Updated 80+ instances of onChange(of:perform:) to use the new
  macOS 14.0+ syntax with two-parameter closures (_, newValue in)
- Commented out unreachable code in LSPService.swift after early return
- Updated Xcode project settings to version 16.1 (LastUpgradeCheck: 2610)
- Enabled app sandbox and JIT runtime exceptions for proper execution
- Added string catalog symbol generation

This resolves all deprecation warnings when targeting macOS 14.0+.

Files affected: 39 files
Changes: 95 insertions(+), 76 deletions(-)
- Fixed remaining onChange(of:perform:) calls that used explicit 'perform:' label
- Updated onChange calls with capture lists to use new two-parameter syntax
- Simplified capture list patterns as new onChange provides both old and new values

Files fixed:
- WorkspacePanelTabBar.swift
- EditorTabButtonStyle.swift
- EditorTabs.swift (2 instances)
- ExtensionsListView.swift

All onChange deprecation warnings now resolved.
The app was crashing with REPORT_APP_ENTITLEMENTS_INSUFFICIENT when
trying to open file/folder dialogs from the Welcome screen.

Added necessary entitlements:
- com.apple.security.app-sandbox: Enable App Sandbox
- com.apple.security.files.user-selected.read-write: Allow user-selected file access
- com.apple.security.files.bookmarks.app-scope: Allow bookmark persistence
- com.apple.security.network.client: Enable network access for extensions/LSP

This resolves the crash when clicking "Open File or Folder" button.
Fixed memory leak where an UnsafeMutablePointer<passwd> was allocated
but never deallocated.

Issue Analysis:
- Line 43 was allocating heap memory for `result` pointer
- getpwuid_r() immediately overwrites `result` to point to `pwd` (stack)
- The allocated heap memory was leaked on every call
- Attempting to deallocate crashed because `result` pointed to stack memory

Root Cause:
The allocation was unnecessary. getpwuid_r() expects `result` as an
output parameter - it sets the pointer itself, no pre-allocation needed.

Solution:
Removed the unnecessary .allocate(capacity: 1) call. Now `result` is
initialized as nil and getpwuid_r() sets it to point to `pwd` on success.

This function is called every time a terminal is opened, so the leak
would accumulate with each terminal session.
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