Skip to content

Migrate from PrivateSentrySDKOnly to SentryObjCSDK.internal #5331

Description

@philprime

sentry-cocoa 9.19.0 introduces a new structured hybrid SDK API via SentrySDK.internal (Swift) and SentryObjCSDK.internal (ObjC). The old PrivateSentrySDKOnly class is deprecated and will be removed in the next major version.

Implementation PR: getsentry/sentry-cocoa#8097
Design doc: SENTRY-INTERNAL-API.md

Benefits

  • Structured, discoverable API. Methods are grouped by feature area instead of one flat class.
  • Deprecation-clean builds. PrivateSentrySDKOnly has deprecation annotations — migrating eliminates warnings.
  • SPM / xcframework compatible. Works with binary distribution — no exposed private headers.

Current Usage

The .NET SDK uses Xamarin/MAUI bindings to PrivateSentrySDKOnly via ApiDefinitions.cs. The binding interface exposes the full PrivateSentrySDKOnly API surface and a patching script (patch-cocoa-bindings.cs) modifies the generated bindings.

The migration involves:

  1. Generating new bindings against the SentryObjCInternalApi headers instead of PrivateSentrySDKOnly.h
  2. Updating the C# wrapper code that calls the bindings
  3. Updating patch-cocoa-bindings.cs for the new API shape

Key Changes

The new ObjC API uses instance methods on [SentryObjCSDK internal] instead of static methods on PrivateSentrySDKOnly.

SDK Metadata

Before (binding) After (binding)
[Static] SetSdkName(string, string) [SentryObjCSDK internal].sdkSetName:version:
[Static] string SdkName { get; } [SentryObjCSDK internal].sdk.name
[Static] string SdkVersionString { get; } [SentryObjCSDK internal].sdk.versionString
[Static] NSDictionary ExtraContext { get; } [SentryObjCSDK internal].sdk.extraContext
[Static] string InstallationID { get; } [SentryObjCSDK internal].sdk.installationID

Profiling

Before (binding) After (binding)
[Static] StartProfilerForTrace(SentryId) [[[SentryObjCSDK internal] profiling] startForTrace:]
[Static] CollectProfileBetween(ulong, ulong, SentryId) [[[SentryObjCSDK internal] profiling] collectBetween:and:forTrace:]
[Static] DiscardProfilerForTrace(SentryId) [[[SentryObjCSDK internal] profiling] discardForTrace:]

Performance & Frames

Before (binding) After (binding)
[Static] bool FramesTrackingMeasurementHybridSDKMode { get; set; } [SentryObjCSDK internal].performance.framesTrackingHybridSDKMode
[Static] bool IsFramesTrackingRunning { get; } [SentryObjCSDK internal].performance.isFramesTrackingRunning
[Static] SentryScreenFrames CurrentScreenFrames { get; } [SentryObjCSDK internal].performance.currentScreenFrames

Screenshot & View Hierarchy

Before (binding) After (binding)
[Static] NSData[] CaptureScreenshots() [[[SentryObjCSDK internal] screenshot] capture]
[Static] NSData CaptureViewHierarchy() [[[SentryObjCSDK internal] viewHierarchy] capture]

Replay

Before (binding) After (binding)
[Static] ConfigureSessionReplayWith(converter, provider) [[[SentryObjCSDK internal] replay] configureBreadcrumbConverter:screenshotProvider:]
[Static] CaptureReplay() (void) [[[SentryObjCSDK internal] replay] capture] → returns BOOL
[Static] string ReplayId { get; } [SentryObjCSDK internal].replay.replayId

Breadcrumbs & Users

Before (binding) After (binding)
[Static] UserWithDictionary(NSDictionary) [[[SentryObjCSDK internal] user] fromDictionary:]
[Static] BreadcrumbWithDictionary(NSDictionary) [[[SentryObjCSDK internal] breadcrumbs] fromDictionary:]

Affected Files (as of latest main)

  • src/Sentry.Bindings.Cocoa/ApiDefinitions.csPrivateSentrySDKOnly binding interface
  • scripts/patch-cocoa-bindings.cs — binding patching script referencing PrivateSentrySDKOnly methods

Checklist

  • Generate new Xamarin/MAUI bindings against SentryObjCInternalApi headers
  • Replace PrivateSentrySDKOnly interface in ApiDefinitions.cs with SentryObjCInternalApi + sub-object interfaces
  • Update patch-cocoa-bindings.cs for new API shape
  • Update C# wrapper code to use new binding methods
  • Handle the static→instance method change (old API was all + class methods, new API uses instance methods on [SentryObjCSDK internal])
  • Bump minimum sentry-cocoa dependency to 9.19.0+
  • Run full test suite to verify no regressions

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions