Skip to content

Commit

Permalink
chore: Remove private references from public headers (#2743)
Browse files Browse the repository at this point in the history
We made SentrySession private but we did not remove references from public headers.

Also changing a few forward declarations to #import to help with .NET hybrid SDK.
  • Loading branch information
brustolin committed Mar 20, 2023
1 parent 1e065bc commit d80d410
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@
D885266427739D01001269FC /* SentryFileIOTrackingIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D885266327739D01001269FC /* SentryFileIOTrackingIntegrationTests.swift */; };
D8853C842833EABC00700D64 /* SentryANRTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BCFA71427D0BAB7008C662C /* SentryANRTracker.h */; };
D88817D826D7149100BF2251 /* SentryTraceContext.m in Sources */ = {isa = PBXBuildFile; fileRef = D88817D626D7149100BF2251 /* SentryTraceContext.m */; };
D88817DA26D72AB800BF2251 /* SentryTraceContext.h in Headers */ = {isa = PBXBuildFile; fileRef = D88817D926D72AB800BF2251 /* SentryTraceContext.h */; };
D88817DA26D72AB800BF2251 /* SentryTraceContext.h in Headers */ = {isa = PBXBuildFile; fileRef = D88817D926D72AB800BF2251 /* SentryTraceContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
D88817DD26D72BA500BF2251 /* SentryTraceStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D88817DB26D72B7B00BF2251 /* SentryTraceStateTests.swift */; };
D8918B222849FA6D00701F9A /* SentrySDKIntegrationTestsBase.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8918B212849FA6D00701F9A /* SentrySDKIntegrationTestsBase.swift */; };
D8AB40DB2806EC1900E5E9F7 /* SentryScreenshotIntegration.h in Headers */ = {isa = PBXBuildFile; fileRef = D8AB40DA2806EC1900E5E9F7 /* SentryScreenshotIntegration.h */; };
Expand Down
6 changes: 2 additions & 4 deletions Sources/Sentry/Public/SentryClient.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#import "SentryDefines.h"

@class SentryOptions, SentrySession, SentryEvent, SentryScope, SentryFileManager, SentryId,
SentryUserFeedback, SentryTransaction;
@class SentryOptions, SentryEvent, SentryScope, SentryFileManager, SentryId, SentryUserFeedback,
SentryTransaction;

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -108,8 +108,6 @@ SENTRY_NO_INIT
- (void)captureUserFeedback:(SentryUserFeedback *)userFeedback
NS_SWIFT_NAME(capture(userFeedback:));

- (void)captureSession:(SentrySession *)session NS_SWIFT_NAME(capture(session:));

/**
* Waits synchronously for the SDK to flush out all queued and cached items for up to the specified
* timeout in seconds. If there is no internet connection, the function returns immediately. The SDK
Expand Down
9 changes: 2 additions & 7 deletions Sources/Sentry/Public/SentryHub.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#import "SentryIntegrationProtocol.h"
#import "SentrySpanProtocol.h"

@class SentryEvent, SentryClient, SentryScope, SentrySession, SentryUser, SentryBreadcrumb,
SentryId, SentryUserFeedback, SentryTransactionContext;
@class SentryEvent, SentryClient, SentryScope, SentryUser, SentryBreadcrumb, SentryId,
SentryUserFeedback, SentryTransactionContext;

NS_ASSUME_NONNULL_BEGIN
@interface SentryHub : NSObject
Expand All @@ -12,11 +12,6 @@ SENTRY_NO_INIT
- (instancetype)initWithClient:(SentryClient *_Nullable)client
andScope:(SentryScope *_Nullable)scope;

/**
* Since there's no scope stack, single hub instance, we keep the session here.
*/
@property (nonatomic, readonly, strong) SentrySession *_Nullable session;

/**
* Starts a new SentrySession. If there's a running SentrySession, it ends it before starting the
* new one. You can use this method in combination with endSession to manually track SentrySessions.
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/SentryHub.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
SentryHub ()

@property (nullable, nonatomic, strong) SentryClient *client;
@property (nullable, nonatomic, strong) SentrySession *session;
@property (nullable, nonatomic, strong) SentryScope *scope;
@property (nonatomic, strong) SentryCrashWrapper *crashWrapper;
@property (nonatomic, strong) SentryTracesSampler *tracesSampler;
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/SentryTraceContext.m
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#import "SentryTraceContext.h"
#import "SentryBaggage.h"
#import "SentryDsn.h"
#import "SentryId.h"
#import "SentryLog.h"
#import "SentryOptions+Private.h"
#import "SentryScope+Private.h"
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/include/HybridPublic/PrivateSentrySDKOnly.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#import "PrivatesHeader.h"
#import "SentryAppStartMeasurement.h"
#import "SentryEnvelope.h"
#import "SentryEnvelopeItemType.h"
#import "SentryScreenFrames.h"

@class SentryEnvelope, SentryDebugMeta, SentryAppStartMeasurement, SentryScreenFrames,
SentryOptions;
@class SentryDebugMeta, SentryAppStartMeasurement, SentryScreenFrames, SentryOptions;

NS_ASSUME_NONNULL_BEGIN

Expand Down
20 changes: 16 additions & 4 deletions Sources/Sentry/include/HybridPublic/SentryEnvelope.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
#import "PrivatesHeader.h"
#import "SentryEnvelopeItemHeader.h"

@class SentryEvent, SentrySession, SentrySdkInfo, SentryId, SentryUserFeedback, SentryAttachment,
SentryTransaction, SentryTraceContext, SentryClientReport, SentryEnvelopeItemHeader;
#if __has_include(<Sentry/SentryEnvelopeItemHeader.h>)
# import <Sentry/SentryEnvelopeItemHeader.h>
#else
# import "SentryEnvelopeItemHeader.h"
#endif

#if COCOAPODS
@class SentrySdkInfo, SentryTraceContext;
#else
# import "SentrySdkInfo.h"
# import "SentryTraceContext.h"

#endif

@class SentryEvent, SentrySession, SentryId, SentryUserFeedback, SentryAttachment,
SentryTransaction, SentryClientReport, SentryEnvelopeItemHeader;

NS_ASSUME_NONNULL_BEGIN

Expand Down
5 changes: 4 additions & 1 deletion Sources/Sentry/include/SentryClient+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#import "SentryDataCategory.h"
#import "SentryDiscardReason.h"

@class SentryEnvelopeItem, SentryId, SentryAttachment, SentryThreadInspector, SentryEnvelope;
@class SentrySession, SentryEnvelopeItem, SentryId, SentryAttachment, SentryThreadInspector,
SentryEnvelope;

NS_ASSUME_NONNULL_BEGIN

Expand Down Expand Up @@ -41,6 +42,8 @@ SentryClient ()
additionalEnvelopeItems:(NSArray<SentryEnvelopeItem *> *)additionalEnvelopeItems
NS_SWIFT_NAME(capture(event:scope:additionalEnvelopeItems:));

- (void)captureSession:(SentrySession *)session NS_SWIFT_NAME(capture(session:));

/**
* Needed by hybrid SDKs as react-native to synchronously store an envelope to disk.
*/
Expand Down
7 changes: 6 additions & 1 deletion Sources/Sentry/include/SentrySdkInfo.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#import "SentrySerializable.h"
#import <Foundation/Foundation.h>

#if __has_include(<Sentry/SentrySerializable.h>)
# import <Sentry/SentrySerializable.h>
#else
# import "SentrySerializable.h"
#endif

NS_ASSUME_NONNULL_BEGIN

/**
Expand Down
13 changes: 11 additions & 2 deletions Sources/Sentry/include/SentryTraceContext.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#import "SentryId.h"
#import "SentrySerializable.h"
#if __has_include(<Sentry/SentrySerializable.h>)
# import <Sentry/SentrySerializable.h>
#else
# import "SentrySerializable.h"
#endif

#if __has_include(<Sentry/SentryId.h>)
# import <Sentry/SentryId.h>
#else
# import "SentryId.h"
#endif

NS_ASSUME_NONNULL_BEGIN

Expand Down
4 changes: 4 additions & 0 deletions develop-docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,7 @@ Date: January 18th, 2023
Contributors: @brustolin and @philipphofmann

We release experimental SentrySwiftUI cocoa package with the version 8.0.0 because all podspecs file in a repo need to have the same version.

## Usage of `__has_include`

Some private headers add a dependency of a public header, when those private headers are used in a sample project, or referenced from a hybrid SDK, it is treated as part of the project using it, therefore, if it points to a header that is not part of said project, a compilation error will occur. To solve this we make use of `__has_include` to try to point to the SDK version of the header, or to fallback to the direct reference when compiling the SDK.

0 comments on commit d80d410

Please sign in to comment.