Skip to content

Commit 270b57d

Browse files
ref: Expose SDKInfo to Swift SDK Code (#3727)
1 parent d90fb20 commit 270b57d

File tree

7 files changed

+33
-9
lines changed

7 files changed

+33
-9
lines changed

Sentry.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@
8080
622C08DB29E554B9002571D4 /* SentrySpanContext+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 622C08D929E554B9002571D4 /* SentrySpanContext+Private.h */; };
8181
62375FB92B47F9F000CC55F1 /* SentryDependencyContainerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 62375FB82B47F9F000CC55F1 /* SentryDependencyContainerTests.swift */; };
8282
623C45B02A651D8200D9E88B /* SentryCoreDataTracker+Test.m in Sources */ = {isa = PBXBuildFile; fileRef = 623C45AF2A651D8200D9E88B /* SentryCoreDataTracker+Test.m */; };
83+
6271ADF32BA06D9B0098D2E9 /* SentryInternalSerializable.h in Headers */ = {isa = PBXBuildFile; fileRef = 6271ADF22BA06D9B0098D2E9 /* SentryInternalSerializable.h */; };
8384
627E7589299F6FE40085504D /* SentryInternalDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = 627E7588299F6FE40085504D /* SentryInternalDefines.h */; };
8485
62862B1C2B1DDBC8009B16E3 /* SentryDelayedFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 62862B1B2B1DDBC8009B16E3 /* SentryDelayedFrame.h */; };
8586
62862B1E2B1DDC35009B16E3 /* SentryDelayedFrame.m in Sources */ = {isa = PBXBuildFile; fileRef = 62862B1D2B1DDC35009B16E3 /* SentryDelayedFrame.m */; };
@@ -973,6 +974,7 @@
973974
62375FB82B47F9F000CC55F1 /* SentryDependencyContainerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryDependencyContainerTests.swift; sourceTree = "<group>"; };
974975
623C45AE2A651C4500D9E88B /* SentryCoreDataTracker+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentryCoreDataTracker+Test.h"; sourceTree = "<group>"; };
975976
623C45AF2A651D8200D9E88B /* SentryCoreDataTracker+Test.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SentryCoreDataTracker+Test.m"; sourceTree = "<group>"; };
977+
6271ADF22BA06D9B0098D2E9 /* SentryInternalSerializable.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryInternalSerializable.h; path = include/SentryInternalSerializable.h; sourceTree = "<group>"; };
976978
627E7588299F6FE40085504D /* SentryInternalDefines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryInternalDefines.h; path = include/SentryInternalDefines.h; sourceTree = "<group>"; };
977979
62862B1B2B1DDBC8009B16E3 /* SentryDelayedFrame.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryDelayedFrame.h; path = include/SentryDelayedFrame.h; sourceTree = "<group>"; };
978980
62862B1D2B1DDC35009B16E3 /* SentryDelayedFrame.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryDelayedFrame.m; sourceTree = "<group>"; };
@@ -1955,6 +1957,7 @@
19551957
D8CB7416294724CC00A5F964 /* SentryEnvelopeAttachmentHeader.m */,
19561958
7BC852382458830A005A70F0 /* SentryEnvelopeItemType.h */,
19571959
6304360F1EC0600A00C4D3FA /* SentrySerializable.h */,
1960+
6271ADF22BA06D9B0098D2E9 /* SentryInternalSerializable.h */,
19581961
639FCF961EBC7B9700778193 /* SentryEvent.h */,
19591962
639FCF971EBC7B9700778193 /* SentryEvent.m */,
19601963
D880E3B02860A5A0008A90DB /* SentryEvent+Private.h */,
@@ -3742,6 +3745,7 @@
37423745
7BE1E32824F7AE08009D3AD0 /* SentrySession+Private.h in Headers */,
37433746
7B5CAF7127F5953400ED0DB6 /* SentryEnvelope+Private.h in Headers */,
37443747
63FE713320DA4C1100CDBAE8 /* SentryCrashCPU.h in Headers */,
3748+
6271ADF32BA06D9B0098D2E9 /* SentryInternalSerializable.h in Headers */,
37453749
D8853C842833EABC00700D64 /* SentryANRTracker.h in Headers */,
37463750
63FE715B20DA4C1100CDBAE8 /* SentryCrashSignalInfo.h in Headers */,
37473751
63FE70E520DA4C1000CDBAE8 /* SentryCrashMonitor_CPPException.h in Headers */,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#import "SentryDefines.h"
2+
#import <Foundation/Foundation.h>
3+
4+
NS_ASSUME_NONNULL_BEGIN
5+
6+
/**
7+
* Use this protocol for internal ObjC classes that are exposed to Swift code by adding them to
8+
* SentryPrivate.h instead of SentrySerializable because CocoaPods throws duplicate header warnings
9+
* when running pod lib lint when using a public protocol on such classes.
10+
*/
11+
@protocol SentryInternalSerializable <NSObject>
12+
SENTRY_NO_INIT
13+
14+
- (NSDictionary<NSString *, id> *)serialize;
15+
16+
@end
17+
18+
NS_ASSUME_NONNULL_END

Sources/Sentry/include/SentryPrivate.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
#import "SentryBaseIntegration.h"
44
#import "SentryRandom.h"
5+
#import "SentrySdkInfo.h"
56
#import "SentryTime.h"

Sources/Sentry/include/SentrySdkInfo.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1+
#import "SentryDefines.h"
2+
#import "SentryInternalSerializable.h"
13
#import <Foundation/Foundation.h>
24

3-
#if __has_include(<Sentry/SentrySerializable.h>)
4-
# import <Sentry/SentrySerializable.h>
5-
#else
6-
# import "SentrySerializable.h"
7-
#endif
8-
95
NS_ASSUME_NONNULL_BEGIN
106

117
/**
128
* Describes the Sentry SDK and its configuration used to capture and transmit an event.
139
* @note Both name and version are required.
1410
* @see https://develop.sentry.dev/sdk/event-payloads/sdk/
1511
*/
16-
@interface SentrySdkInfo : NSObject <SentrySerializable>
12+
@interface SentrySdkInfo : NSObject <SentryInternalSerializable>
1713
SENTRY_NO_INIT
1814

1915
/**

Sources/Sentry/include/SentrySpan.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
NS_ASSUME_NONNULL_BEGIN
55

66
@class SentryTracer, SentryId, SentrySpanId, SentryFrame, SentrySpanContext;
7-
@protocol SentrySerializable;
87

98
#if SENTRY_HAS_UIKIT
109
@class SentryFramesTracker;

Tests/SentryTests/SentryTests-Bridging-Header.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@
162162
#import "SentryScreenFrames.h"
163163
#import "SentryScreenshot.h"
164164
#import "SentryScreenshotIntegration.h"
165-
#import "SentrySdkInfo.h"
166165
#import "SentrySwift.h"
167166
#import "SentrySwiftAsyncIntegration.h"
168167

develop-docs/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ When making an Objective-C class public for Swift SDK code, do the following:
137137
* Add the import `@_implementationOnly import _SentryPrivate` to your Swift class that wants to use
138138
the Objective-C class.
139139

140+
## Public Protocols
141+
142+
pod lib lint fails with the warning duplicate protocol definition when including a public header for
143+
a protocol in a private ObjC class header, when adding that header to `SentryPrivate.h` to expose it
144+
to internal SDK Swift code, as `SentrySDKInfo.h`. To solve this problem we have to use the
145+
`SentryInternalSerializable` for internal classes implementing serializable.
146+
140147
### Detailed explanation of the Swift and Objective-C Interoperability setup
141148

142149
The SentrySDK uses Swift and Objective-C code. Public Objective-C classes, made public

0 commit comments

Comments
 (0)