Repository navigation
fix(macos): link ServiceManagement weakly for macOS 12 - #87
Merged
Merged
Conversation
## Problem On macOS 12 the built `cnativeapi` library fails to load:
Member
|
Thanks @yx-wh for the macOS 12 fix and your Monterey verification! Merged as 472b2ad, and the workspace core pointer has been updated. Together with nativeapi #20, this is now shipped in Dart release v0.5.7, covering cnativeapi, nativeapi, and nativeapi_flutter. All three packages were published successfully and their pub.dev archives were verified. Our CMake and Dart native-asset builds targeting macOS 12 also confirmed weak ServiceManagement load commands and weak SMAppService imports. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On macOS 12 the built
cnativeapilibrary fails to load:Every FFI entry point then throws, even for unrelated APIs such as the tray
icon or the shortcut manager, because the library never loads.
Root cause
ServiceManagementis linked normally, andSMAppServiceonly exists onmacOS 13+. The build uses the current macOS SDK, so
__has_include(<ServiceManagement/SMAppService.h>)is always true and_OBJC_CLASS_$_SMAppServiceis emitted as a required (non-weak) symbol.The
@available(macOS 13.0, *)guards inlaunch_at_login_macos.mmonlyprevent execution; they do not remove the compile-time symbol reference.
Fix
Link the framework weakly so the library loads on macOS 12, where the
existing availability checks then keep
Enable()/Disable()/IsEnabled()returning false. Behaviour on macOS 13+ is unchanged.Verification
Built and run on macOS 12 (Monterey, x86_64) with
MACOSX_DEPLOYMENT_TARGET = 12.0:The app starts normally and tray/shortcut APIs work. Launch-at-login reports
"unsupported" on macOS 12, which is expected.
Companion to libnativeapi/nativeapi#20