Skip to content

Commit da63814

Browse files
committed
fix: Accessing SentryLevel from ObjC types
1 parent dcaec4e commit da63814

26 files changed

+521
-571
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
These components run in separate processes or sandboxes with different execution characteristics, which can cause false positive app hang reports.
4646
- [HTTP Client errors](https://docs.sentry.io/platforms/apple/guides/ios/configuration/http-client-errors/) now mark sessions as errored (#6633)
4747
- The Package.swift has swift-tools-version set to 6.0 (#6764)
48+
- Converts the `SentryLevel` enum to be written in ObjC (#6802)
4849

4950
### Features
5051

Samples/SPM/SPM/SPMTestApp.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ struct SPMTestApp: App {
1313
SentrySDK.start(options: options)
1414
let user = User()
1515
SentrySDK.setUser(user)
16+
let breadcrumb = Breadcrumb(level: .error, category: "test")
17+
SentrySDK.addBreadcrumb(breadcrumb)
1618
}
1719

1820
var body: some Scene {

Sentry.xcodeproj/project.pbxproj

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,6 @@
908908
D8709ACB2D3F848E006C491E /* SentryReplayMaskPreviewUIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8709ACA2D3F8480006C491E /* SentryReplayMaskPreviewUIView.swift */; };
909909
D8709ACD2D3F84CF006C491E /* PreviewRedactOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8709ACC2D3F84C9006C491E /* PreviewRedactOptions.swift */; };
910910
D8739D142BEE5049007D2F66 /* SentryRRWebSpanEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8739D132BEE5049007D2F66 /* SentryRRWebSpanEvent.swift */; };
911-
D8739D172BEEA33F007D2F66 /* SentryLevelHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = D8739D152BEEA33F007D2F66 /* SentryLevelHelper.h */; };
912-
D8739D182BEEA33F007D2F66 /* SentryLevelHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = D8739D162BEEA33F007D2F66 /* SentryLevelHelper.m */; };
913911
D8751FA5274743710032F4DE /* SentryNSURLSessionTaskSearchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8751FA4274743710032F4DE /* SentryNSURLSessionTaskSearchTests.swift */; };
914912
D875ED0B276CC84700422FAC /* SentryFileIOTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D875ED0A276CC84700422FAC /* SentryFileIOTrackerTests.swift */; };
915913
D880E3A728573E87008A90DB /* SentryBaggageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D880E3A628573E87008A90DB /* SentryBaggageTests.swift */; };
@@ -1047,6 +1045,7 @@
10471045
FA3AEE782E68E2830092283E /* SentryEnvelopeHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA3AEE772E68E2830092283E /* SentryEnvelopeHeader.swift */; };
10481046
FA458CC32E691A730061B13D /* SentryProcessInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA458CBD2E691A6E0061B13D /* SentryProcessInfo.swift */; };
10491047
FA4C32972DF7513F001D7B00 /* SentryExperimentalOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4C32962DF7513F001D7B00 /* SentryExperimentalOptions.swift */; };
1048+
FA4FB82B2ECB7D2A008C9EC3 /* SentryLevel.h in Headers */ = {isa = PBXBuildFile; fileRef = FA4FB8252ECB7D27008C9EC3 /* SentryLevel.h */; settings = {ATTRIBUTES = (Public, ); }; };
10501049
FA560F602E8C877200F2AF7F /* SentryAppStateManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA560F5A2E8C876A00F2AF7F /* SentryAppStateManager.swift */; };
10511050
FA6252042EB52DD900BFC967 /* SentryHub.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA6251FE2EB52DD700BFC967 /* SentryHub.swift */; };
10521051
FA6252062EB5489E00BFC967 /* SentryClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA6252052EB5489B00BFC967 /* SentryClient.swift */; };
@@ -2281,8 +2280,6 @@
22812280
D8709ACA2D3F8480006C491E /* SentryReplayMaskPreviewUIView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryReplayMaskPreviewUIView.swift; sourceTree = "<group>"; };
22822281
D8709ACC2D3F84C9006C491E /* PreviewRedactOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PreviewRedactOptions.swift; sourceTree = "<group>"; };
22832282
D8739D132BEE5049007D2F66 /* SentryRRWebSpanEvent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryRRWebSpanEvent.swift; sourceTree = "<group>"; };
2284-
D8739D152BEEA33F007D2F66 /* SentryLevelHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryLevelHelper.h; path = include/SentryLevelHelper.h; sourceTree = "<group>"; };
2285-
D8739D162BEEA33F007D2F66 /* SentryLevelHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryLevelHelper.m; sourceTree = "<group>"; };
22862283
D8751FA4274743710032F4DE /* SentryNSURLSessionTaskSearchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryNSURLSessionTaskSearchTests.swift; sourceTree = "<group>"; };
22872284
D8757D142A209F7300BFEFCC /* SentrySampleDecision+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentrySampleDecision+Private.h"; path = "include/SentrySampleDecision+Private.h"; sourceTree = "<group>"; };
22882285
D875ED0A276CC84700422FAC /* SentryFileIOTrackerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SentryFileIOTrackerTests.swift; sourceTree = "<group>"; };
@@ -2429,6 +2426,7 @@
24292426
FA458CBD2E691A6E0061B13D /* SentryProcessInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryProcessInfo.swift; sourceTree = "<group>"; };
24302427
FA4C32962DF7513F001D7B00 /* SentryExperimentalOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryExperimentalOptions.swift; sourceTree = "<group>"; };
24312428
FA4C32972DF7513F001D7B01 /* SentryAppState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryAppState.swift; sourceTree = "<group>"; };
2429+
FA4FB8252ECB7D27008C9EC3 /* SentryLevel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryLevel.h; path = Public/SentryLevel.h; sourceTree = "<group>"; };
24322430
FA560F5A2E8C876A00F2AF7F /* SentryAppStateManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryAppStateManager.swift; sourceTree = "<group>"; };
24332431
FA6251FE2EB52DD700BFC967 /* SentryHub.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryHub.swift; sourceTree = "<group>"; };
24342432
FA6252052EB5489B00BFC967 /* SentryClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryClient.swift; sourceTree = "<group>"; };
@@ -2950,6 +2948,7 @@
29502948
639889D51EDF10BE00EA7442 /* Helper */ = {
29512949
isa = PBXGroup;
29522950
children = (
2951+
FA4FB8252ECB7D27008C9EC3 /* SentryLevel.h */,
29532952
63AA76951EB9C1C200D153DE /* SentryDefines.h */,
29542953
627E7588299F6FE40085504D /* SentryInternalDefines.h */,
29552954
0A9E917028DC7E7000FB4182 /* SentryInternalCDefines.h */,
@@ -2988,8 +2987,6 @@
29882987
844EDC75294144DB00C86F34 /* SentrySystemWrapper.mm */,
29892988
FAB359972E05D7E90083D5E3 /* SentryEventSwiftHelper.h */,
29902989
FAB359992E05D8080083D5E3 /* SentryEventSwiftHelper.m */,
2991-
D8739D152BEEA33F007D2F66 /* SentryLevelHelper.h */,
2992-
D8739D162BEEA33F007D2F66 /* SentryLevelHelper.m */,
29932990
F452438B2DE65BC0003E8F50 /* SentryUseNSExceptionCallstackWrapper.h */,
29942991
F452437D2DE60B71003E8F50 /* SentryUseNSExceptionCallstackWrapper.m */,
29952992
);
@@ -5167,7 +5164,6 @@
51675164
7D0637032382B34300B30749 /* SentryScope.h in Headers */,
51685165
03F84D2727DD414C008FE43F /* SentryMachLogging.hpp in Headers */,
51695166
63295AF51EF3C7DB002D4490 /* SentryNSDictionarySanitize.h in Headers */,
5170-
D8739D172BEEA33F007D2F66 /* SentryLevelHelper.h in Headers */,
51715167
8E4A037825F6F52100000D77 /* SentrySampleDecision.h in Headers */,
51725168
63FE717920DA4C1100CDBAE8 /* SentryCrashReportStore.h in Headers */,
51735169
A839D89824864B80003B7AFD /* SentrySystemEventBreadcrumbs.h in Headers */,
@@ -5201,6 +5197,7 @@
52015197
63FE710320DA4C1000CDBAE8 /* SentryCrashMachineContext_Apple.h in Headers */,
52025198
D8479328278873A100BE8E99 /* SentryByteCountFormatter.h in Headers */,
52035199
928207C42E251B8F009285A4 /* SentryScope+PrivateSwift.h in Headers */,
5200+
FA4FB82B2ECB7D2A008C9EC3 /* SentryLevel.h in Headers */,
52045201
63AA76981EB9C1C200D153DE /* SentryClient.h in Headers */,
52055202
0A9E917128DC7E7000FB4182 /* SentryInternalCDefines.h in Headers */,
52065203
63FE711F20DA4C1000CDBAE8 /* SentryCrashObjC.h in Headers */,
@@ -6009,7 +6006,6 @@
60096006
D451ED5D2D92ECD200C9BEA8 /* SentryOnDemandReplayError.swift in Sources */,
60106007
628308612D50ADAC00EAEF77 /* SentryRequestCodable.swift in Sources */,
60116008
03F84D3827DD4191008FE43F /* SentryBacktrace.cpp in Sources */,
6012-
D8739D182BEEA33F007D2F66 /* SentryLevelHelper.m in Sources */,
60136009
63FE712720DA4C1000CDBAE8 /* SentryCrashThread.c in Sources */,
60146010
F429D37F2E8532A300DBF387 /* HttpDateParser.swift in Sources */,
60156011
7B127B0F27CF6F4700A71ED2 /* SentryANRTrackingIntegration.m in Sources */,

Sources/Sentry/Public/Sentry.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ FOUNDATION_EXPORT const unsigned char SentryVersionString[];
2323
# import <Sentry/SentryGeo.h>
2424
# import <Sentry/SentryHttpStatusCodeRange.h>
2525
# import <Sentry/SentryId.h>
26+
# import <Sentry/SentryLevel.h>
2627
# import <Sentry/SentryMeasurementUnit.h>
2728
# import <Sentry/SentryMechanism.h>
2829
# import <Sentry/SentryMechanismContext.h>

Sources/Sentry/Public/SentryBreadcrumb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# import <SentryDefines.h>
88
#endif
99
#import SENTRY_HEADER(SentrySerializable)
10+
#import SENTRY_HEADER(SentryLevel)
1011

1112
NS_ASSUME_NONNULL_BEGIN
1213

Sources/Sentry/Public/SentryDefines.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,6 @@ typedef BOOL (^SentryShouldQueueEvent)(
138138
typedef NSNumber *_Nullable (^SentryTracesSamplerCallback)(
139139
SentrySamplingContext *_Nonnull samplingContext);
140140

141-
/**
142-
* Sentry level.
143-
*/
144-
typedef NS_ENUM(NSUInteger,
145-
SentryLevel); // This is a forward declaration, the actual enum is implemented in Swift.
146-
147141
static NSUInteger const defaultMaxBreadcrumbs = 100;
148142

149143
static NSString *_Nonnull const kSentryTrueString = @"true";

Sources/Sentry/Public/SentryEvent.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# import <SentryDefines.h>
88
#endif
99
#import SENTRY_HEADER(SentrySerializable)
10+
#import SENTRY_HEADER(SentryLevel)
1011

1112
NS_ASSUME_NONNULL_BEGIN
1213

@@ -54,7 +55,7 @@ NS_SWIFT_NAME(Event)
5455
/**
5556
* @c SentryLevel of the event.
5657
*/
57-
@property (nonatomic) enum SentryLevel level;
58+
@property (nonatomic) SentryLevel level;
5859

5960
/**
6061
* This will be used for symbolicating on the server should be "cocoa".

Sources/Sentry/Public/SentryScope.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#endif
88
#import SENTRY_HEADER(SentrySerializable)
99
#import SENTRY_HEADER(SentrySpanProtocol)
10+
#import SENTRY_HEADER(SentryLevel)
1011

1112
@class SentryAttachment;
1213
@class SentryBreadcrumb;
@@ -100,7 +101,7 @@ NS_SWIFT_NAME(Scope)
100101
/**
101102
* Sets the @c level in the scope
102103
*/
103-
- (void)setLevel:(enum SentryLevel)level;
104+
- (void)setLevel:(SentryLevel)level;
104105

105106
/**
106107
* Add a breadcrumb to the scope

Sources/Sentry/SentryBreadcrumb.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#import "SentryBreadcrumb+Private.h"
33
#import "SentryDateUtils.h"
44
#import "SentryInternalDefines.h"
5+
#import "SentryLevel.h"
56
#import "SentryLevelMapper.h"
67
#import "SentryNSDictionarySanitize.h"
78
#import "SentrySwift.h"
@@ -39,7 +40,7 @@ - (instancetype)initWithDictionary:(NSDictionary *)dictionary
3940
return self;
4041
}
4142

42-
- (instancetype)initWithLevel:(enum SentryLevel)level category:(NSString *)category
43+
- (instancetype)initWithLevel:(SentryLevel)level category:(NSString *)category
4344
{
4445
self = [super init];
4546
if (self) {

Sources/Sentry/SentryEvent.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ - (instancetype)init
3333
return [self commonInit:kSentryLevelNone];
3434
}
3535

36-
- (instancetype)initWithLevel:(enum SentryLevel)level
36+
- (instancetype)initWithLevel:(SentryLevel)level
3737
{
3838
self = [super init];
3939
return [self commonInit:level];
4040
}
4141

42-
- (instancetype)commonInit:(enum SentryLevel)level
42+
- (instancetype)commonInit:(SentryLevel)level
4343
{
4444
if (self) {
4545
self.eventId = [[SentryId alloc] init];

0 commit comments

Comments
 (0)