Skip to content

Commit c08c7b4

Browse files
committed
Experimental options in Swift
1 parent 1c358ac commit c08c7b4

File tree

7 files changed

+88
-20
lines changed

7 files changed

+88
-20
lines changed

Sentry.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@
10351035
FA67DD172DDBD4EA00896B02 /* SentryLogOutput.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCEC2DDBD4EA00896B02 /* SentryLogOutput.swift */; };
10361036
FA67DD182DDBD4EA00896B02 /* UIImageHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCED2DDBD4EA00896B02 /* UIImageHelper.swift */; };
10371037
FA67DD192DDBD4EA00896B02 /* SwizzleClassNameExclude.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCD52DDBD4EA00896B02 /* SwizzleClassNameExclude.swift */; };
1038+
FA8A35B72DEA93160058D883 /* Options+Swift.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8A35B62DEA93160058D883 /* Options+Swift.swift */; };
10381039
/* End PBXBuildFile section */
10391040

10401041
/* Begin PBXContainerItemProxy section */
@@ -2248,6 +2249,7 @@
22482249
FA67DCEF2DDBD4EA00896B02 /* URLSessionTaskHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionTaskHelper.swift; sourceTree = "<group>"; };
22492250
FA67DCF12DDBD4EA00896B02 /* SentryExperimentalOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryExperimentalOptions.swift; sourceTree = "<group>"; };
22502251
FA67DCF22DDBD4EA00896B02 /* SwiftDescriptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftDescriptor.swift; sourceTree = "<group>"; };
2252+
FA8A35B62DEA93160058D883 /* Options+Swift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Options+Swift.swift"; sourceTree = "<group>"; };
22512253
/* End PBXFileReference section */
22522254

22532255
/* Begin PBXFrameworksBuildPhase section */
@@ -2379,6 +2381,7 @@
23792381
621D9F2D2B9B030E003D94DE /* Helper */ = {
23802382
isa = PBXGroup;
23812383
children = (
2384+
FA8A35B62DEA93160058D883 /* Options+Swift.swift */,
23822385
84B0E0062CD963F9007FB332 /* SentryIconography.swift */,
23832386
621F61F02BEA073A005E654F /* SentryEnabledFeaturesBuilder.swift */,
23842387
);
@@ -5193,6 +5196,7 @@
51935196
7BA61CAD247BAA0B00C130A8 /* SentryDebugImageProvider.m in Sources */,
51945197
63FE70E720DA4C1000CDBAE8 /* SentryCrashMonitor.c in Sources */,
51955198
84354E1229BF944900CDBB8B /* SentryProfileTimeseries.mm in Sources */,
5199+
FA8A35B72DEA93160058D883 /* Options+Swift.swift in Sources */,
51965200
D85852B627ECEEDA00C6D8AE /* SentryScreenshot.m in Sources */,
51975201
7D5C441C237C2E1F00DAB0A3 /* SentryHub.m in Sources */,
51985202
84E13B842CBF1D91003B52EC /* SentryUserFeedbackWidgetButtonMegaphoneIconView.swift in Sources */,

Sources/Sentry/Public/SentryOptions.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
NS_ASSUME_NONNULL_BEGIN
1111

1212
@class SentryDsn;
13-
@class SentryExperimentalOptions;
1413
@class SentryHttpStatusCodeRange;
1514
@class SentryMeasurementValue;
1615
@class SentryReplayOptions;
@@ -782,11 +781,9 @@ typedef void (^SentryProfilingConfigurationBlock)(SentryProfileOptions *_Nonnull
782781
*/
783782
@property (nonatomic, copy) NSString *spotlightUrl;
784783

785-
/**
786-
* This aggregates options for experimental features.
787-
* Be aware that the options available for experimental can change at any time.
788-
*/
789-
@property (nonatomic, readonly) SentryExperimentalOptions *experimental;
784+
// Do not use this directly, instead use the non-underscored `experimental` property that is
785+
// defined through a Swift extension.
786+
@property (nonatomic, readonly) NSObject *_swiftExperimentalOptions;
790787

791788
#if TARGET_OS_IOS && SENTRY_HAS_UIKIT
792789

Sources/Sentry/SentryOptions.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ - (instancetype)init
125125
self.enableTimeToFullDisplayTracing = NO;
126126

127127
self.initialScope = ^SentryScope *(SentryScope *scope) { return scope; };
128-
_experimental = [[SentryExperimentalOptions alloc] init];
128+
__swiftExperimentalOptions = [[SentryExperimentalOptions alloc] init];
129129
_enableTracing = NO;
130130
_enableTracingManual = NO;
131131
#if SENTRY_HAS_UIKIT

Sources/Sentry/SentryTransportAdapter.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#import "SentryEnvelope.h"
33
#import "SentryEvent.h"
44
#import "SentryOptions.h"
5+
#import "SentrySwift.h"
56
#import "SentryUserFeedback.h"
67

78
NS_ASSUME_NONNULL_BEGIN

Sources/Sentry/include/SentrySwift.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
# elif __has_include(<Sentry/Sentry-Swift.h>)
3535
# import <Sentry/Sentry-Swift.h>
3636
# else
37-
@import SentrySwift;
37+
@import SentrySwift;
3838
# endif
3939
#endif // __has_include(<SentryWithoutUIKit/Sentry.h>)
4040

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Makes the `experimental` property visible as the Swift type `SentryExperimentalOptions`.
2+
// This works around `SentryExperimentalOptions` being only forward declared in the objc header.
3+
@objc
4+
extension Options {
5+
6+
/**
7+
* This aggregates options for experimental features.
8+
* Be aware that the options available for experimental can change at any time.
9+
*/
10+
@objc
11+
open var experimental: SentryExperimentalOptions {
12+
// We know the type so it's fine to force cast.
13+
// swiftlint:disable force_cast
14+
_swiftExperimentalOptions as! SentryExperimentalOptions
15+
// swiftlint:enable force_cast
16+
}
17+
}

sdk_api.json

Lines changed: 61 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21653,21 +21653,21 @@
2165321653
},
2165421654
{
2165521655
"kind": "Var",
21656-
"name": "experimental",
21657-
"printedName": "experimental",
21656+
"name": "_swiftExperimentalOptions",
21657+
"printedName": "_swiftExperimentalOptions",
2165821658
"children": [
2165921659
{
2166021660
"kind": "TypeNominal",
21661-
"name": "SentryExperimentalOptions",
21662-
"printedName": "Sentry.SentryExperimentalOptions",
21663-
"usr": "c:@M@Sentry@objc(cs)SentryExperimentalOptions"
21661+
"name": "NSObject",
21662+
"printedName": "ObjectiveC.NSObject",
21663+
"usr": "c:objc(cs)NSObject"
2166421664
}
2166521665
],
2166621666
"declKind": "Var",
21667-
"usr": "c:objc(cs)SentryOptions(py)experimental",
21667+
"usr": "c:objc(cs)SentryOptions(py)_swiftExperimentalOptions",
2166821668
"moduleName": "Sentry",
2166921669
"isOpen": true,
21670-
"objc_name": "experimental",
21670+
"objc_name": "_swiftExperimentalOptions",
2167121671
"declAttributes": [
2167221672
"ObjC",
2167321673
"Dynamic"
@@ -21680,16 +21680,16 @@
2168021680
"children": [
2168121681
{
2168221682
"kind": "TypeNominal",
21683-
"name": "SentryExperimentalOptions",
21684-
"printedName": "Sentry.SentryExperimentalOptions",
21685-
"usr": "c:@M@Sentry@objc(cs)SentryExperimentalOptions"
21683+
"name": "NSObject",
21684+
"printedName": "ObjectiveC.NSObject",
21685+
"usr": "c:objc(cs)NSObject"
2168621686
}
2168721687
],
2168821688
"declKind": "Accessor",
21689-
"usr": "c:objc(cs)SentryOptions(im)experimental",
21689+
"usr": "c:objc(cs)SentryOptions(im)_swiftExperimentalOptions",
2169021690
"moduleName": "Sentry",
2169121691
"isOpen": true,
21692-
"objc_name": "experimental",
21692+
"objc_name": "_swiftExperimentalOptions",
2169321693
"declAttributes": [
2169421694
"DiscardableResult",
2169521695
"ObjC",
@@ -21914,6 +21914,55 @@
2191421914
"Dynamic"
2191521915
],
2191621916
"init_kind": "Designated"
21917+
},
21918+
{
21919+
"kind": "Var",
21920+
"name": "experimental",
21921+
"printedName": "experimental",
21922+
"children": [
21923+
{
21924+
"kind": "TypeNominal",
21925+
"name": "SentryExperimentalOptions",
21926+
"printedName": "Sentry.SentryExperimentalOptions",
21927+
"usr": "c:@M@Sentry@objc(cs)SentryExperimentalOptions"
21928+
}
21929+
],
21930+
"declKind": "Var",
21931+
"usr": "c:@CM@Sentry@@objc(cs)SentryOptions(py)experimental",
21932+
"mangledName": "$sSo13SentryOptionsC0A0E12experimentalAC0a12ExperimentalB0Cvp",
21933+
"moduleName": "Sentry",
21934+
"isOpen": true,
21935+
"declAttributes": [
21936+
"Dynamic",
21937+
"ObjC"
21938+
],
21939+
"isFromExtension": true,
21940+
"accessors": [
21941+
{
21942+
"kind": "Accessor",
21943+
"name": "Get",
21944+
"printedName": "Get()",
21945+
"children": [
21946+
{
21947+
"kind": "TypeNominal",
21948+
"name": "SentryExperimentalOptions",
21949+
"printedName": "Sentry.SentryExperimentalOptions",
21950+
"usr": "c:@M@Sentry@objc(cs)SentryExperimentalOptions"
21951+
}
21952+
],
21953+
"declKind": "Accessor",
21954+
"usr": "c:@CM@Sentry@@objc(cs)SentryOptions(im)experimental",
21955+
"mangledName": "$sSo13SentryOptionsC0A0E12experimentalAC0a12ExperimentalB0Cvg",
21956+
"moduleName": "Sentry",
21957+
"isOpen": true,
21958+
"declAttributes": [
21959+
"Dynamic",
21960+
"ObjC"
21961+
],
21962+
"isFromExtension": true,
21963+
"accessorKind": "get"
21964+
}
21965+
]
2191721966
}
2191821967
],
2191921968
"declKind": "Class",

0 commit comments

Comments
 (0)