Fix: Application cannot be opened.#61
Open
andoan16 wants to merge 2 commits into
Open
Conversation
…ction The .NET single-file bundle extracts native libraries (libSkiaSharp.dylib, libHarfBuzzSharp.dylib, libAvaloniaNative.dylib) to ~/.net/ at runtime. macOS hardened runtime rejects these dylibs because their Team ID differs from the main executable, causing SIGABRT before the UI even appears. Root cause: IncludeNativeLibrariesForSelfExtract=true causes .NET to extract native dylibs to a temp directory where they fail signature validation under hardened runtime. Changes: - MacUtilGUI.fsproj: set IncludeNativeLibrariesForSelfExtract=false so native libs stay in the bundle directory alongside the executable instead of being extracted at runtime - MacUtilGUI.entitlements: add com.apple.security.cs.disable-library-validation entitlement to allow loading libraries with different Team IDs (defense-in-depth for .NET runtime assemblies) - build_universal.sh: merge .dylib files with lipo instead of rsync-ing x64-only copies; ad-hoc sign dylibs and bundle after build so dev builds run without manual codesign workarounds - sign_macos.sh: sign native .dylib files individually before deep-signing the bundle, ensuring consistent Developer ID signatures
When IncludeNativeLibrariesForSelfExtract=false, .NET SDK requires IncludeAllContentForSelfExtract to also be false (error NETSDK1143). This ensures native dylibs stay as separate files in the publish output alongside the executable, not embedded in the single-file bundle.
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, MacUtil-Universal.app crashes immediately with the error:
The app quits unexpectedly (SIGABRT) before the UI even appears.
Root Cause
.NET
PublishSingleFilewithIncludeNativeLibrariesForSelfExtract=trueextracts native libraries (libSkiaSharp.dylib,libHarfBuzzSharp.dylib,libAvaloniaNative.dylib) to a temp directory (~/.net/MacUtilGUI/...) at runtime. macOS hardened runtime rejects these dylibs because their code signature has a different Team ID from the main executable:This causes
System.DllNotFoundException→System.TypeInitializationException→ SIGABRT.Changes
MacUtilGUI.fsproj— SetIncludeNativeLibrariesForSelfExtract=falseso native dylibs stay in the bundle directory (Contents/MacOS/) alongside the executable instead of being extracted to~/.net/at runtime. This eliminates the signature mismatch entirely.MacUtilGUI.entitlements— Addcom.apple.security.cs.disable-library-validationentitlement as defense-in-depth. This allows the .NET runtime to load libraries with different Team IDs, covering edge cases where dylibs may still be extracted or loaded from external paths.build_universal.sh— Instead ofrsync-ing x64-only.dylibfiles, merge each native library withlipointo universal binaries (matching the main executable). Added ad-hoc signing step for dylibs and bundle after build, so dev builds run without manualcodesign/xattrworkarounds.sign_macos.sh— Added a step to individually sign each.dylibwith the Developer ID before deep-signing the bundle. This ensures native libraries have consistent signatures that match the main executable under hardened runtime.Testing
SIGABRT,DllNotFoundExceptionforlibSkiaSharp)codesign --force --deep --sign - --options=0x0(ad-hoc, no hardened runtime) as a manual workaround → app launched successfully.fsprojchange (IncludeNativeLibrariesForSelfExtract=false) is the definitive fix: native libs remain in the bundle where they share the app's signature, so no extraction-related mismatch can occur