Repository navigation
fix(macos): link ServiceManagement weakly so the library loads on macOS 12 - #20
Merged
Merged
Conversation
…OS 12 ## Problem On macOS 12 the built `cnativeapi` library fails to load:
Member
|
Thanks @yx-wh for the fix and for verifying it on macOS 12! This PR and nativeapi-core #87 have been merged. The fix is now published in v0.5.7: cnativeapi 0.5.7, nativeapi 0.5.7, and nativeapi_flutter 0.5.7. We also verified the macOS 12-targeted CMake and Dart native-asset builds have weak ServiceManagement load commands and weak SMAppService imports. The release workflow passed, and we checked that the published cnativeapi archive includes both linking changes. |
yx-wh
added a commit
to yx-wh/Ciyue
that referenced
this pull request
Nov 2, 2026
… link cnativeapi 0.5.7 links ServiceManagement weakly upstream (libnativeapi/nativeapi#20 and nativeapi-core#87), so patching the package after pub get is no longer needed. Bump the lock file and drop the CI step and the script.
yx-wh
added a commit
to yx-wh/Ciyue
that referenced
this pull request
Nov 2, 2026
cnativeapi 0.5.7 links ServiceManagement weakly upstream (libnativeapi/nativeapi#20, nativeapi-core#87), so the app no longer needs a post-pub-get patch to load on macOS 12. Bump the lock file; the earlier weak-link patch and its CI step are dropped because they are now redundant.
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.The CMake path needs the same change; that file lives in
nativeapi-core,so a companion PR is open there: nativeapi-core/pull/87.
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-core#87