Skip to content

ref: migrate Cocoa bindings from PrivateSentrySDKOnly to SentryObjCSDK.internal - #5409

Merged
jamescrosswell merged 27 commits into
mainfrom
migrate-private-sentrysdk-only-5331
Jul 24, 2026
Merged

ref: migrate Cocoa bindings from PrivateSentrySDKOnly to SentryObjCSDK.internal#5409
jamescrosswell merged 27 commits into
mainfrom
migrate-private-sentrysdk-only-5331

Conversation

@jamescrosswell

@jamescrosswell jamescrosswell commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Migrates the iOS / Mac Catalyst hybrid-SDK bindings off the deprecated PrivateSentrySDKOnly (static methods, slated for removal in the next sentry-cocoa major) to the structured SentryObjCSDK.internal API introduced in sentry-cocoa 9.19. main already pins sentry-cocoa 9.22.0, so no dependency bump is required.

Key incremental/separate commits, in case this helps for review purposes:

  • Phase 1 — regenerate bindings against the SentryObjC headers (build-sentry-cocoa.sh, generate-cocoa-bindings.ps1, patch-cocoa-bindings.cs, ApiDefinitions.cs). PrivateSentrySDKOnly kept in parallel - e532a2f
  • Phase 2 — migrate the 5 call sites and the SentryCocoaHybridSdk alias to the new instance-based API cada275
  • Phase 3 — remove PrivateSentrySDKOnly from the binding, patch/generate scripts, and props 55ff0b8

Note: We build from source now

  • The .NET-consumed surface is only 5 call sites, via the SentryCocoaHybridSdk MSBuild alias (SetSdkName, SetTrace, StartProfilerForTrace, CollectProfileBetween, IgnoreNextSignal). Every one has a direct equivalent within [SentryObjCSDK internal].
  • ⚠️ The published SentryObjC-Dynamic.xcframework is not usable as-is. It is fully self-contained (~4.4 MB/slice): it defines SentryHubInternal, SentryClientInternal, SentryObjCSDK and the SentrySwift classes, and links no external Sentry.framework. Bundling it alongside the Sentry.framework we already ship would put two full copies of the SDK in the app, with split runtime state — the managed bindings would talk to one instance and the new internal calls to another.
  • sentry-cocoa exposes a buildable SentryObjC Xcode scheme; it builds cleanly and ships the SentryObjCSDK / SentryObjCInternalApi public headers.
  • Building SentryObjC + SentryObjCCompat from source produces thin two frameworks (136 KB + 1.2 MB) that only define the new additive SentryObjC* wrapper types and import the real SDK classes (_SentryScope, _SentryBreadcrumb, _SentryUser, …) as undefined symbols resolved at load time from the existing Sentry.framework via @rpath. No duplication; the new API shares the same SDK instance as the current bindings.

Issues

Closes #5331

jamescrosswell and others added 2 commits July 20, 2026 16:16
…ternal

Opens the branch/PR for the phased migration off the deprecated
PrivateSentrySDKOnly hybrid API (#5331). Phases land as subsequent commits.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Phase 1 of migrating the Cocoa hybrid API off the deprecated
PrivateSentrySDKOnly to the structured SentryObjCSDK.internal API.

- build-sentry-cocoa.sh now also builds the SentryObjC and SentryObjCCompat
  schemes from source into thin xcframeworks (iOS, iOS-sim, Mac Catalyst).
  These dynamically link the existing Sentry.framework rather than embedding
  their own copy of the SDK, so they don't duplicate it - unlike the
  self-contained released SentryObjC-Dynamic.xcframework.
- generate-cocoa-bindings.ps1 feeds the SentryObjC entry-point, internal-API,
  and id headers to Objective Sharpie.
- patch-cocoa-bindings.cs keeps the new interfaces and trims SentryObjCSDK to
  its `internal` accessor and SentryObjCInternalApi to the members the .NET
  wrappers use (sdk, profiling, setTrace, ignoreNextSignal).
- Sentry.Bindings.Cocoa.csproj bundles the two new frameworks via NativeReference.

PrivateSentrySDKOnly is kept in parallel; call sites migrate in phase 2.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.61%. Comparing base (65c0c59) to head (6e57539).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5409      +/-   ##
==========================================
+ Coverage   74.58%   74.61%   +0.02%     
==========================================
  Files         512      512              
  Lines       18666    18672       +6     
  Branches     3659     3657       -2     
==========================================
+ Hits        13922    13932      +10     
+ Misses       3869     3866       -3     
+ Partials      875      874       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

jamescrosswell and others added 4 commits July 20, 2026 17:07
Phase 2: repoint the SentryCocoaHybridSdk alias from PrivateSentrySDKOnly to
SentryObjCSDK and move the five call sites onto the new instance-based API:

- SetSdkName        -> Internal.Sdk.Name =
- SetTrace          -> Internal.SetTrace (using the new SentryObjCId / SentryObjCSpanId)
- StartProfilerForTrace -> Internal.Profiling.StartFor
- CollectProfileBetween -> Internal.Profiling.CollectBetweenStartTime
- IgnoreNextSignal  -> Internal.IgnoreNextSignal

MiscExtensions gains ToCocoaObjCId / ToCocoaObjCSpanId for the new id types and
drops the now-unused ToCocoaSentryId / ToCocoaSpanId.

Sentry builds for net10.0-ios26 and net10.0-maccatalyst26 with no warnings.
PrivateSentrySDKOnly is still bound (removed in phase 3).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The 10.0.302 workload ships the iOS SDK pack 26.5.10301, which requires
Xcode 26.6. CI was pinning Xcode 26.5, causing iOS/MacCatalyst builds and
device tests to fail. The macos-26 runner already used by these jobs has
Xcode 26.6 available, so switch the pin to it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Dependabot bumped only codeql-action/init to 4.37.1, leaving analyze on
4.37.0. CodeQL requires all steps use the same version, so analyze failed
with "Loaded a configuration file for version '4.37.1', but running
version '4.37.0'". Pin analyze to the same v4.37.1 SHA.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@jamescrosswell
jamescrosswell changed the base branch from main to fix/5406-pin-xcode-26.6 July 21, 2026 01:06
Base automatically changed from fix/5406-pin-xcode-26.6 to main July 21, 2026 03:35
jamescrosswell and others added 5 commits July 21, 2026 15:41
xcodebuild embeds each framework's dynamic dependencies under
<Framework>.framework/Frameworks/, producing deeply nested paths
(SentryObjC.framework/Frameworks/SentryObjCCompat.framework/Frameworks/Sentry.framework)
that exceed NuGet's path-length limit and fail packing with NU5123. We bundle
Sentry, SentryObjCCompat and SentryObjC as separate NativeReferences (each
embedded into the consuming app and resolved via @rpath), so the nested copies
are redundant. Strip them after building the xcframeworks.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The new SentryObjCSDK.internal profiling API returns an immutable NSDictionary,
whereas the old PrivateSentrySDKOnly.collectProfileBetween returned a mutable
one. CocoaProfiler.Collect mutates the payload (adds transaction id/trace_id/
name/timestamp), which threw NotSupportedException on the immutable dictionary
and failed Profiler_RunningUnderFullClient_SendsProfileData. Copy it into an
NSMutableDictionary first.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The app bundle now contains the SentryObjC and SentryObjCCompat frameworks
alongside Sentry.framework, so sentry-cli uploads their debug symbols too.
Add them to the expected upload list.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Phase 3: all call sites migrated to SentryObjCSDK.internal in the previous
phase, so drop the deprecated PrivateSentrySDKOnly interface entirely - the
header no longer feeds Objective Sharpie, the patch rules that shaped it are
gone, and the regenerated ApiDefinitions.cs loses the interface (pure removal,
no other changes). sentry-cocoa removes the class in its next major.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread scripts/generate-cocoa-bindings.ps1
Comment thread scripts/generate-cocoa-bindings.ps1 Outdated
Comment thread scripts/patch-cocoa-bindings.cs Outdated
Comment thread scripts/patch-cocoa-bindings.cs Outdated
Comment thread src/Sentry/Platforms/Cocoa/CocoaProfiler.cs Outdated
Comment thread src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj Outdated
Co-authored-by: James Crosswell <jamescrosswell@users.noreply.github.com>
Comment thread scripts/build-sentry-cocoa.sh Outdated
jamescrosswell and others added 4 commits July 23, 2026 10:35
…entry/sentry-dotnet into migrate-private-sentrysdk-only-5331
The previous comment implied the SentryObjCCompat/SentryObjC order was a
requirement. These are dynamic frameworks whose inter-dependencies are recorded
in their own Mach-O load commands and resolved by dyld via @rpath at load time,
so the item order has no functional effect - it's dependency-first purely for
readability.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Comment thread src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj Outdated
Comment thread src/Sentry.Bindings.Cocoa/Sentry.Bindings.Cocoa.csproj Outdated
jamescrosswell and others added 2 commits July 23, 2026 10:47
Co-authored-by: James Crosswell <jamescrosswell@users.noreply.github.com>
The comment's closing --> was accidentally replaced with a Unicode arrow,
leaving the comment unterminated so the project file failed to load
(NETSDK: "An XML comment cannot contain '--'"), which broke every CI job
at environment setup.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate from PrivateSentrySDKOnly to SentryObjCSDK.internal

3 participants