Skip to content

Commit 7e16c0c

Browse files
authored
Experimental options in Swift (#5329)
* Experimental options in Swift * Add changelog * Fix project file
1 parent 9aa0b44 commit 7e16c0c

File tree

6 files changed

+555
-490
lines changed

6 files changed

+555
-490
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Converted SentryUserFeedback from Objective-C to Swift (#5377)
1212
- Crashes for uncaught NSExceptions will now report the stracktrace recorded within the exception (#5306)
1313
- Fix usage of `@available` to be `iOS` instead of `iOSApplicationExtension` (#5361)
14+
- Move SentryExperimentalOptions to a property defined in Swift (#5329)
1415

1516
## 8.52.1
1617

Sentry.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,8 +1022,8 @@
10221022
F49D419C2DEA30C300D9244E /* SentryCrashExceptionApplicationHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = F49D419B2DEA30B800D9244E /* SentryCrashExceptionApplicationHelper.h */; };
10231023
F49D419E2DEA3D0600D9244E /* SentryCrashExceptionApplicationHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = F49D419D2DEA3D0300D9244E /* SentryCrashExceptionApplicationHelper.m */; };
10241024
FA034AC82DD3DB4900FE3107 /* SentryIntegrationProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = FA034AC72DD3DB4900FE3107 /* SentryIntegrationProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
1025+
FA4C32972DF7513F001D7B00 /* SentryExperimentalOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4C32962DF7513F001D7B00 /* SentryExperimentalOptions.swift */; };
10251026
FA67DCC12DDBD4C800896B02 /* SentryLog+Configure.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCC02DDBD4C800896B02 /* SentryLog+Configure.swift */; };
1026-
FA67DCF42DDBD4EA00896B02 /* SentryExperimentalOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCF12DDBD4EA00896B02 /* SentryExperimentalOptions.swift */; };
10271027
FA67DCF52DDBD4EA00896B02 /* SentryCurrentDateProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCCA2DDBD4EA00896B02 /* SentryCurrentDateProvider.swift */; };
10281028
FA67DCF62DDBD4EA00896B02 /* SentryViewRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCE52DDBD4EA00896B02 /* SentryViewRenderer.swift */; };
10291029
FA67DCF72DDBD4EA00896B02 /* SentryDefaultMaskRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCDF2DDBD4EA00896B02 /* SentryDefaultMaskRenderer.swift */; };
@@ -2264,6 +2264,7 @@
22642264
F49D419B2DEA30B800D9244E /* SentryCrashExceptionApplicationHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryCrashExceptionApplicationHelper.h; sourceTree = "<group>"; };
22652265
F49D419D2DEA3D0300D9244E /* SentryCrashExceptionApplicationHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryCrashExceptionApplicationHelper.m; sourceTree = "<group>"; };
22662266
FA034AC72DD3DB4900FE3107 /* SentryIntegrationProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryIntegrationProtocol.h; path = Public/SentryIntegrationProtocol.h; sourceTree = "<group>"; };
2267+
FA4C32962DF7513F001D7B00 /* SentryExperimentalOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryExperimentalOptions.swift; sourceTree = "<group>"; };
22672268
FA67DCC02DDBD4C800896B02 /* SentryLog+Configure.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "SentryLog+Configure.swift"; sourceTree = "<group>"; };
22682269
FA67DCC22DDBD4EA00896B02 /* Locks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Locks.swift; sourceTree = "<group>"; };
22692270
FA67DCC32DDBD4EA00896B02 /* NumberExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NumberExtensions.swift; sourceTree = "<group>"; };
@@ -2301,7 +2302,6 @@
23012302
FA67DCED2DDBD4EA00896B02 /* UIImageHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIImageHelper.swift; sourceTree = "<group>"; };
23022303
FA67DCEE2DDBD4EA00896B02 /* UrlSanitized.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UrlSanitized.swift; sourceTree = "<group>"; };
23032304
FA67DCEF2DDBD4EA00896B02 /* URLSessionTaskHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionTaskHelper.swift; sourceTree = "<group>"; };
2304-
FA67DCF12DDBD4EA00896B02 /* SentryExperimentalOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryExperimentalOptions.swift; sourceTree = "<group>"; };
23052305
FA67DCF22DDBD4EA00896B02 /* SwiftDescriptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftDescriptor.swift; sourceTree = "<group>"; };
23062306
FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryThread+Private.h"; path = "include/SentryThread+Private.h"; sourceTree = "<group>"; };
23072307
FAEC270D2DF3526000878871 /* SentryUserFeedback.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUserFeedback.swift; sourceTree = "<group>"; };
@@ -4101,6 +4101,7 @@
41014101
D8F016B12B9622B7007B9AFB /* Protocol */,
41024102
D856272A2A374A6800FB8062 /* Tools */,
41034103
D8B665BB2B95F5A100BD0E7B /* module.modulemap */,
4104+
FA4C32962DF7513F001D7B00 /* SentryExperimentalOptions.swift */,
41044105
);
41054106
path = Swift;
41064107
sourceTree = "<group>";
@@ -4586,7 +4587,6 @@
45864587
FA67DCDA2DDBD4EA00896B02 /* MetricKit */,
45874588
FA67DCDE2DDBD4EA00896B02 /* Protocol */,
45884589
FA67DCF02DDBD4EA00896B02 /* Tools */,
4589-
FA67DCF12DDBD4EA00896B02 /* SentryExperimentalOptions.swift */,
45904590
FA67DCF22DDBD4EA00896B02 /* SwiftDescriptor.swift */,
45914591
);
45924592
path = Core;
@@ -5407,7 +5407,6 @@
54075407
849B8F9A2C6E906900148E1F /* SentryUserFeedbackConfiguration.swift in Sources */,
54085408
63295AF71EF3C7DB002D4490 /* SentryNSDictionarySanitize.m in Sources */,
54095409
7B8ECBFC26498958005FE2EF /* SentryAppStateManager.m in Sources */,
5410-
FA67DCF42DDBD4EA00896B02 /* SentryExperimentalOptions.swift in Sources */,
54115410
FA67DCF52DDBD4EA00896B02 /* SentryCurrentDateProvider.swift in Sources */,
54125411
FA67DCF62DDBD4EA00896B02 /* SentryViewRenderer.swift in Sources */,
54135412
FA67DCF72DDBD4EA00896B02 /* SentryDefaultMaskRenderer.swift in Sources */,
@@ -5440,6 +5439,7 @@
54405439
FA67DD122DDBD4EA00896B02 /* Locks.swift in Sources */,
54415440
FA67DD132DDBD4EA00896B02 /* NumberExtensions.swift in Sources */,
54425441
FA67DD142DDBD4EA00896B02 /* SentryGraphicsImageRenderer.swift in Sources */,
5442+
FA4C32972DF7513F001D7B00 /* SentryExperimentalOptions.swift in Sources */,
54435443
FA67DD152DDBD4EA00896B02 /* UrlSanitized.swift in Sources */,
54445444
FA67DD162DDBD4EA00896B02 /* SentryViewPhotographer.swift in Sources */,
54455445
FA67DD172DDBD4EA00896B02 /* SentryLogOutput.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/Swift/Core/SentryExperimentalOptions.swift renamed to Sources/Swift/SentryExperimentalOptions.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,21 @@ public class SentryExperimentalOptions: NSObject {
3434
@_spi(Private) public func validateOptions(_ options: [String: Any]?) {
3535
}
3636
}
37+
38+
// Makes the `experimental` property visible as the Swift type `SentryExperimentalOptions`.
39+
// This works around `SentryExperimentalOptions` being only forward declared in the objc header.
40+
@objc
41+
extension Options {
42+
43+
/**
44+
* This aggregates options for experimental features.
45+
* Be aware that the options available for experimental can change at any time.
46+
*/
47+
@objc
48+
open var experimental: SentryExperimentalOptions {
49+
// We know the type so it's fine to force cast.
50+
// swiftlint:disable force_cast
51+
_swiftExperimentalOptions as! SentryExperimentalOptions
52+
// swiftlint:enable force_cast
53+
}
54+
}

0 commit comments

Comments
 (0)