Skip to content

Commit 75b23cd

Browse files
authored
ref: Convert SentryObjCRuntimeWrapper and SentryDefaultObjCRuntimeWrapper to Swift (#6023)
* ref: Convert `SentryObjCRuntimeWrapper` and `SentryDefaultObjCRuntimeWrapper` to Swift * ref: Enhance `LoadValidator` to include `objcRuntimeWrapper` parameter for SDK duplication checks
1 parent e446901 commit 75b23cd

20 files changed

+80
-64
lines changed

Sentry.xcodeproj/project.pbxproj

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -593,9 +593,6 @@
593593
7BF9EF762722B34700B5BBEF /* SentrySubClassFinder.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BF9EF752722B34700B5BBEF /* SentrySubClassFinder.h */; };
594594
7BF9EF782722B35D00B5BBEF /* SentrySubClassFinder.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BF9EF772722B35D00B5BBEF /* SentrySubClassFinder.m */; };
595595
7BF9EF7A2722B58900B5BBEF /* SentrySubClassFinderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BF9EF792722B58900B5BBEF /* SentrySubClassFinderTests.swift */; };
596-
7BF9EF7C2722B90E00B5BBEF /* SentryDefaultObjCRuntimeWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BF9EF7B2722B90E00B5BBEF /* SentryDefaultObjCRuntimeWrapper.h */; };
597-
7BF9EF7E2722B91F00B5BBEF /* SentryDefaultObjCRuntimeWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BF9EF7D2722B91F00B5BBEF /* SentryDefaultObjCRuntimeWrapper.m */; };
598-
7BF9EF842722D07B00B5BBEF /* SentryObjCRuntimeWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BF9EF832722D07B00B5BBEF /* SentryObjCRuntimeWrapper.h */; };
599596
7BF9EF862722D10600B5BBEF /* SentryTestObjCRuntimeWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BF9EF852722D10600B5BBEF /* SentryTestObjCRuntimeWrapper.h */; };
600597
7BF9EF882722D13000B5BBEF /* SentryTestObjCRuntimeWrapper.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BF9EF872722D13000B5BBEF /* SentryTestObjCRuntimeWrapper.m */; };
601598
7BF9EF8B2722D58700B5BBEF /* SentryInitializeForGettingSubclassesNotCalled.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BF9EF8A2722D58700B5BBEF /* SentryInitializeForGettingSubclassesNotCalled.m */; };
@@ -1048,6 +1045,8 @@
10481045
F4DCC9DD2E4AA9D0008ECE45 /* SentrySDKSettingsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4DCC9DC2E4AA9D0008ECE45 /* SentrySDKSettingsTests.swift */; };
10491046
F4DCC9E52E4AACE0008ECE45 /* SentrySDKSettings+Equality.m in Sources */ = {isa = PBXBuildFile; fileRef = F4DCC9E42E4AACE0008ECE45 /* SentrySDKSettings+Equality.m */; };
10501047
F4E3DCCB2E1579240093CB80 /* SentryScopePersistentStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4E3DCCA2E1579240093CB80 /* SentryScopePersistentStore.swift */; };
1048+
F4FE9DFD2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE9DFB2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift */; };
1049+
F4FE9DFE2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE9DFC2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift */; };
10511050
F4FE9DBD2E621F100014FED5 /* SentryRandom.swift in Sources */ = {isa = PBXBuildFile; fileRef = F4FE9DBC2E621F100014FED5 /* SentryRandom.swift */; };
10521051
FA034AC82DD3DB4900FE3107 /* SentryIntegrationProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = FA034AC72DD3DB4900FE3107 /* SentryIntegrationProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
10531052
FA21F0B42E4A2A80008B4E5A /* SentryAppState.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4C32972DF7513F001D7B01 /* SentryAppState.swift */; };
@@ -1872,9 +1871,6 @@
18721871
7BF9EF752722B34700B5BBEF /* SentrySubClassFinder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentrySubClassFinder.h; path = include/SentrySubClassFinder.h; sourceTree = "<group>"; };
18731872
7BF9EF772722B35D00B5BBEF /* SentrySubClassFinder.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentrySubClassFinder.m; sourceTree = "<group>"; };
18741873
7BF9EF792722B58900B5BBEF /* SentrySubClassFinderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySubClassFinderTests.swift; sourceTree = "<group>"; };
1875-
7BF9EF7B2722B90E00B5BBEF /* SentryDefaultObjCRuntimeWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryDefaultObjCRuntimeWrapper.h; path = include/SentryDefaultObjCRuntimeWrapper.h; sourceTree = "<group>"; };
1876-
7BF9EF7D2722B91F00B5BBEF /* SentryDefaultObjCRuntimeWrapper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryDefaultObjCRuntimeWrapper.m; sourceTree = "<group>"; };
1877-
7BF9EF832722D07B00B5BBEF /* SentryObjCRuntimeWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryObjCRuntimeWrapper.h; path = include/SentryObjCRuntimeWrapper.h; sourceTree = "<group>"; };
18781874
7BF9EF852722D10600B5BBEF /* SentryTestObjCRuntimeWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryTestObjCRuntimeWrapper.h; sourceTree = "<group>"; };
18791875
7BF9EF872722D13000B5BBEF /* SentryTestObjCRuntimeWrapper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryTestObjCRuntimeWrapper.m; sourceTree = "<group>"; };
18801876
7BF9EF892722D57100B5BBEF /* SentryInitializeForGettingSubclassesNotCalled.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryInitializeForGettingSubclassesNotCalled.h; sourceTree = "<group>"; };
@@ -2393,6 +2389,8 @@
23932389
F4DCC9E32E4AACE0008ECE45 /* SentrySDKSettings+Equality.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentrySDKSettings+Equality.h"; sourceTree = "<group>"; };
23942390
F4DCC9E42E4AACE0008ECE45 /* SentrySDKSettings+Equality.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SentrySDKSettings+Equality.m"; sourceTree = "<group>"; };
23952391
F4E3DCCA2E1579240093CB80 /* SentryScopePersistentStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScopePersistentStore.swift; sourceTree = "<group>"; };
2392+
F4FE9DFB2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryDefaultObjCRuntimeWrapper.swift; sourceTree = "<group>"; };
2393+
F4FE9DFC2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryObjCRuntimeWrapper.swift; sourceTree = "<group>"; };
23962394
F4FE9DBC2E621F100014FED5 /* SentryRandom.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryRandom.swift; sourceTree = "<group>"; };
23972395
FA034AC72DD3DB4900FE3107 /* SentryIntegrationProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryIntegrationProtocol.h; path = Public/SentryIntegrationProtocol.h; sourceTree = "<group>"; };
23982396
FA3734812E0EEA670091EF24 /* SentryScreenshot.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScreenshot.swift; sourceTree = "<group>"; };
@@ -2607,6 +2605,8 @@
26072605
FA8E58F02E0AD4220049F69D /* SentryDispatchQueueWrapper.swift */,
26082606
84B0E0062CD963F9007FB332 /* SentryIconography.swift */,
26092607
621F61F02BEA073A005E654F /* SentryEnabledFeaturesBuilder.swift */,
2608+
F4FE9DFB2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift */,
2609+
F4FE9DFC2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift */,
26102610
);
26112611
path = Helper;
26122612
sourceTree = "<group>";
@@ -2929,9 +2929,6 @@
29292929
7B8ECBFB26498958005FE2EF /* SentryAppStateManager.m */,
29302930
7BD86EC4264A63F6005439DB /* SentrySysctl.h */,
29312931
7BD86EC6264A641D005439DB /* SentrySysctl.m */,
2932-
7BF9EF832722D07B00B5BBEF /* SentryObjCRuntimeWrapper.h */,
2933-
7BF9EF7B2722B90E00B5BBEF /* SentryDefaultObjCRuntimeWrapper.h */,
2934-
7BF9EF7D2722B91F00B5BBEF /* SentryDefaultObjCRuntimeWrapper.m */,
29352932
D8479327278873A100BE8E99 /* SentryByteCountFormatter.h */,
29362933
D84793242788737D00BE8E99 /* SentryByteCountFormatter.m */,
29372934
7B2A70DA27D607CF008B0D15 /* SentryThreadWrapper.h */,
@@ -5021,7 +5018,6 @@
50215018
33EB2A922C341300004FED3D /* Sentry.h in Headers */,
50225019
7B3398632459C14000BD9C96 /* SentryEnvelopeRateLimit.h in Headers */,
50235020
6304360A1EC0595B00C4D3FA /* SentryNSDataUtils.h in Headers */,
5024-
7BF9EF7C2722B90E00B5BBEF /* SentryDefaultObjCRuntimeWrapper.h in Headers */,
50255021
FA6555142E30181B009917BC /* SentrySDKInternal.h in Headers */,
50265022
63FE718720DA4C1100CDBAE8 /* SentryCrashReportVersion.h in Headers */,
50275023
0A56DA5F28ABA01B00C400D5 /* SentryTransactionContext+Private.h in Headers */,
@@ -5079,7 +5075,6 @@
50795075
7BF9EF762722B34700B5BBEF /* SentrySubClassFinder.h in Headers */,
50805076
7BC852332458802C005A70F0 /* SentryDataCategoryMapper.h in Headers */,
50815077
7BDB03B7251364F800BAE198 /* _SentryDispatchQueueWrapperInternal.h in Headers */,
5082-
7BF9EF842722D07B00B5BBEF /* SentryObjCRuntimeWrapper.h in Headers */,
50835078
621AE74B2C626C230012E730 /* SentryANRTrackerV2.h in Headers */,
50845079
639889B71EDECFA800EA7442 /* SentryBreadcrumbTracker.h in Headers */,
50855080
632331F9240506DF008D91D6 /* SentryScope+Private.h in Headers */,
@@ -5829,13 +5824,14 @@
58295824
620467AC2D3FFD230025F06C /* SentryNSErrorCodable.swift in Sources */,
58305825
639FCFA51EBC809A00778193 /* SentryStacktrace.m in Sources */,
58315826
D84D2CC32C29AD120011AF8A /* SentrySessionReplay.swift in Sources */,
5827+
F4FE9DFD2E622CD70014FED5 /* SentryDefaultObjCRuntimeWrapper.swift in Sources */,
5828+
F4FE9DFE2E622CD70014FED5 /* SentryObjCRuntimeWrapper.swift in Sources */,
58325829
84A898542E163072009A551E /* SentryProfileConfiguration.m in Sources */,
58335830
849B8F9B2C6E906900148E1F /* SentryUserFeedbackIntegrationDriver.swift in Sources */,
58345831
FA3734862E0F09320091EF24 /* SentryDependencyContainerSwiftHelper.m in Sources */,
58355832
63FE70DF20DA4C1000CDBAE8 /* SentryCrashMonitorType.c in Sources */,
58365833
D468C0622D3669A200964230 /* SentryFileIOTracker+SwiftHelpers.swift in Sources */,
58375834
F49236EB2E5E4B2F00663673 /* SentryBinaryImageCache.swift in Sources */,
5838-
7BF9EF7E2722B91F00B5BBEF /* SentryDefaultObjCRuntimeWrapper.m in Sources */,
58395835
7BC3936E25B1AB72004F03D3 /* SentryLevelMapper.m in Sources */,
58405836
6304360B1EC0595B00C4D3FA /* SentryNSDataUtils.m in Sources */,
58415837
D81988C52BEC18CA0020E36C /* SentryRRWebCustomEvent.swift in Sources */,

Sources/Sentry/SentryDefaultObjCRuntimeWrapper.m

Lines changed: 0 additions & 16 deletions
This file was deleted.

Sources/Sentry/SentryDependencyContainer.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#import "SentryANRTrackerV1.h"
22

33
#import "SentryApplication.h"
4-
#import "SentryDefaultObjCRuntimeWrapper.h"
54
#import "SentryDispatchFactory.h"
65
#import "SentryDisplayLinkWrapper.h"
76
#import "SentryExtraContextProvider.h"

Sources/Sentry/SentrySubClassFinder.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#import "SentrySubClassFinder.h"
2+
#import "SentryInternalDefines.h"
23
#import "SentryLogC.h"
3-
#import "SentryObjCRuntimeWrapper.h"
44
#import "SentrySwift.h"
55
#import <objc/runtime.h>
66
#import <string.h>
@@ -43,9 +43,14 @@ - (void)actOnSubclassesOfViewControllerInImage:(NSString *)imageName block:(void
4343
return;
4444
}
4545

46+
const char *_Nullable cImageName = [imageName cStringUsingEncoding:NSUTF8StringEncoding];
47+
if (cImageName == nil) {
48+
return;
49+
}
50+
4651
unsigned int count = 0;
4752
const char **classes = [self.objcRuntimeWrapper
48-
copyClassNamesForImage:[imageName cStringUsingEncoding:NSUTF8StringEncoding]
53+
copyClassNamesForImage:SENTRY_UNWRAP_NULLABLE(const char, cImageName)
4954
amount:&count];
5055

5156
SENTRY_LOG_DEBUG(@"Found %u number of classes in image: %@.", count, imageName);

Sources/Sentry/SentryUIViewControllerSwizzling.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#if SENTRY_HAS_UIKIT
44

5-
# import "SentryDefaultObjCRuntimeWrapper.h"
65
# import "SentryDefines.h"
76
# import "SentryDependencyContainer.h"
87
# import "SentryLogC.h"

Sources/Sentry/include/SentryDefaultObjCRuntimeWrapper.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

Sources/Sentry/include/SentryObjCRuntimeWrapper.h

Lines changed: 0 additions & 9 deletions
This file was deleted.

Sources/Sentry/include/SentryPrivate.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#import "SentryCrashUUIDConversion.h"
99
#import "SentryEventSwiftHelper.h"
1010
#import "SentryNSDataUtils.h"
11-
#import "SentryObjCRuntimeWrapper.h"
1211
#import "SentryTime.h"
1312
#import "SentryUserAccess.h"
1413
#import "_SentryDispatchQueueWrapperInternal.h"

Sources/Sentry/include/SentrySubClassFinder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#import "SentryDefines.h"
2-
#import "SentryObjCRuntimeWrapper.h"
32

43
NS_ASSUME_NONNULL_BEGIN
54

5+
@protocol SentryObjCRuntimeWrapper;
6+
67
@class SentryDefaultObjCRuntimeWrapper;
78
@class SentryDispatchQueueWrapper;
89

Sources/Sentry/include/SentryUIViewControllerSwizzling.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
#if SENTRY_HAS_UIKIT
44

5-
# import "SentryObjCRuntimeWrapper.h"
65
# import <UIKit/UIKit.h>
76

87
NS_ASSUME_NONNULL_BEGIN
98

9+
@protocol SentryObjCRuntimeWrapper;
10+
1011
@class SentryBinaryImageCache;
1112
@class SentryDispatchQueueWrapper;
1213
@class SentryNSProcessInfoWrapper;

0 commit comments

Comments
 (0)