Remove Swift ObjC classes from Apple crypto native shim#128917
Open
vcsjones wants to merge 3 commits into
Open
Remove Swift ObjC classes from Apple crypto native shim#128917vcsjones wants to merge 3 commits into
vcsjones wants to merge 3 commits into
Conversation
Replace Swift class-backed opaque handles with typed pointer-backed Swift value types so loading multiple copies of the Apple crypto native library does not register duplicate ObjC classes in the process. Add a native build validation script that fails if future Swift bindings introduce locally-defined Swift ObjC class metadata. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
|
Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the Apple crypto native shim to avoid emitting Swift/ObjC class metadata (which is process-global) by replacing class-backed opaque handles with pointer-backed Swift value types. It also adds a post-build validation step to prevent reintroducing Swift ObjC class definitions in the future.
Changes:
- Replace
final classhandle wrappers inpal_swiftbindings.swiftwith value types stored behind typedUnsafeMutablePointer<T>allocations, eliminating local Swift ObjC classes. - Add a new
verify-no-swift-objc-classes.shscript that scans the built binary/archive for Swift ObjC class definitions. - Wire the new verification into the Apple crypto native library CMake post-build steps (shared + static).
Show a summary per file
| File | Description |
|---|---|
| src/native/libs/verify-no-swift-objc-classes.sh | New validation script to detect Swift ObjC class definitions in the produced binary/archive. |
| src/native/libs/System.Security.Cryptography.Native.Apple/pal_swiftbindings.swift | Replaces class-backed handles with pointer-backed value types to avoid Swift ObjC class registration. |
| src/native/libs/System.Security.Cryptography.Native.Apple/CMakeLists.txt | Adds post-build invocation of the new validation script for shared and static outputs. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 1
bartonjs
approved these changes
Jun 2, 2026
am11
reviewed
Jun 2, 2026
Co-authored-by: Adeel Mujahid <3840695+am11@users.noreply.github.com>
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.
Replace Swift class-backed opaque handles with typed pointer-backed Swift value types so loading multiple copies of the Apple crypto native library does not register duplicate ObjC classes in the process.
Add a native build validation script that fails if future Swift bindings introduce locally-defined Swift ObjC class metadata so that we don't run in to this problem again, since it is basically impossible to catch in CI.
Fixes #128867