Skip to content

Commit 3ffd0e5

Browse files
authored
ref: Convert SentryProcessInfoWrapper to Swift (#6072)
* ref: Convert SentryProcessInfoWrapper to Swift * Rename
1 parent 3b373bb commit 3ffd0e5

37 files changed

+99
-165
lines changed

Sentry.xcodeproj/project.pbxproj

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,6 @@
650650
843FB3232D0CD04D00558F18 /* SentryUserAccess.m in Sources */ = {isa = PBXBuildFile; fileRef = 843FB3222D0CD04D00558F18 /* SentryUserAccess.m */; };
651651
843FB3242D0CD04D00558F18 /* SentryUserAccess.h in Headers */ = {isa = PBXBuildFile; fileRef = 843FB3212D0CD04D00558F18 /* SentryUserAccess.h */; };
652652
843FB3432D156B9900558F18 /* SentryFeedbackTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 843FB3412D156B9900558F18 /* SentryFeedbackTests.swift */; };
653-
844EDC6F294143B900C86F34 /* SentryNSProcessInfoWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 844EDC6D294143B900C86F34 /* SentryNSProcessInfoWrapper.h */; };
654-
844EDC70294143B900C86F34 /* SentryNSProcessInfoWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 844EDC6E294143B900C86F34 /* SentryNSProcessInfoWrapper.mm */; };
655653
844EDC76294144DB00C86F34 /* SentrySystemWrapper.h in Headers */ = {isa = PBXBuildFile; fileRef = 844EDC74294144DB00C86F34 /* SentrySystemWrapper.h */; };
656654
844EDC77294144DB00C86F34 /* SentrySystemWrapper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 844EDC75294144DB00C86F34 /* SentrySystemWrapper.mm */; };
657655
844EDD6C2949387000C86F34 /* SentryMetricProfiler.h in Headers */ = {isa = PBXBuildFile; fileRef = 844EDD6B2949387000C86F34 /* SentryMetricProfiler.h */; };
@@ -1056,6 +1054,7 @@
10561054
FA3854362E267DA60045A563 /* SentryUser+Serialize.h in Headers */ = {isa = PBXBuildFile; fileRef = FA3854352E267DA20045A563 /* SentryUser+Serialize.h */; };
10571055
FA3A42722E1C5F9B00A08C39 /* SentryNSNotificationCenterWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA3A42712E1C5F9B00A08C39 /* SentryNSNotificationCenterWrapper.swift */; };
10581056
FA3AEE782E68E2830092283E /* SentryEnvelopeHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA3AEE772E68E2830092283E /* SentryEnvelopeHeader.swift */; };
1057+
FA458CC32E691A730061B13D /* SentryProcessInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA458CBD2E691A6E0061B13D /* SentryProcessInfo.swift */; };
10591058
FA4C32972DF7513F001D7B00 /* SentryExperimentalOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA4C32962DF7513F001D7B00 /* SentryExperimentalOptions.swift */; };
10601059
FA6555142E30181B009917BC /* SentrySDKInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = FA6555132E30181B009917BC /* SentrySDKInternal.h */; };
10611060
FA6555162E30182B009917BC /* SentrySDKInternal.m in Sources */ = {isa = PBXBuildFile; fileRef = FA6555152E30182B009917BC /* SentrySDKInternal.m */; };
@@ -1953,8 +1952,6 @@
19531952
844DA81D28246DAE00E6B62E /* develop-docs */ = {isa = PBXFileReference; lastKnownFileType = folder; path = "develop-docs"; sourceTree = "<group>"; };
19541953
844DA81E28246DB900E6B62E /* fastlane */ = {isa = PBXFileReference; lastKnownFileType = folder; path = fastlane; sourceTree = "<group>"; };
19551954
844DA81F28246DE300E6B62E /* scripts */ = {isa = PBXFileReference; lastKnownFileType = folder; path = scripts; sourceTree = "<group>"; };
1956-
844EDC6D294143B900C86F34 /* SentryNSProcessInfoWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryNSProcessInfoWrapper.h; path = include/SentryNSProcessInfoWrapper.h; sourceTree = "<group>"; };
1957-
844EDC6E294143B900C86F34 /* SentryNSProcessInfoWrapper.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryNSProcessInfoWrapper.mm; sourceTree = "<group>"; };
19581955
844EDC712941442200C86F34 /* TestSentryNSProcessInfoWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSentryNSProcessInfoWrapper.swift; sourceTree = "<group>"; };
19591956
844EDC74294144DB00C86F34 /* SentrySystemWrapper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentrySystemWrapper.h; path = include/SentrySystemWrapper.h; sourceTree = "<group>"; };
19601957
844EDC75294144DB00C86F34 /* SentrySystemWrapper.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentrySystemWrapper.mm; sourceTree = "<group>"; };
@@ -2402,6 +2399,7 @@
24022399
FA3854352E267DA20045A563 /* SentryUser+Serialize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryUser+Serialize.h"; path = "include/SentryUser+Serialize.h"; sourceTree = "<group>"; };
24032400
FA3A42712E1C5F9B00A08C39 /* SentryNSNotificationCenterWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryNSNotificationCenterWrapper.swift; sourceTree = "<group>"; };
24042401
FA3AEE772E68E2830092283E /* SentryEnvelopeHeader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryEnvelopeHeader.swift; sourceTree = "<group>"; };
2402+
FA458CBD2E691A6E0061B13D /* SentryProcessInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryProcessInfo.swift; sourceTree = "<group>"; };
24052403
FA4C32962DF7513F001D7B00 /* SentryExperimentalOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryExperimentalOptions.swift; sourceTree = "<group>"; };
24062404
FA4C32972DF7513F001D7B01 /* SentryAppState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryAppState.swift; sourceTree = "<group>"; };
24072405
FA6555132E30181B009917BC /* SentrySDKInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentrySDKInternal.h; path = include/SentrySDKInternal.h; sourceTree = "<group>"; };
@@ -2602,6 +2600,7 @@
26022600
621D9F2D2B9B030E003D94DE /* Helper */ = {
26032601
isa = PBXGroup;
26042602
children = (
2603+
FA458CBD2E691A6E0061B13D /* SentryProcessInfo.swift */,
26052604
F4A930222E65FDAF006DA6EF /* SentryMobileProvisionParser.swift */,
26062605
F4FE9DBC2E621F100014FED5 /* SentryRandom.swift */,
26072606
F48F767B2E60B555009D4E7D /* SentryNSTimerFactory.swift */,
@@ -2941,8 +2940,6 @@
29412940
7B18DE3F28D9F748004845C6 /* SentryNotificationNames.h */,
29422941
84A8891A28DBD28900C51DFD /* SentryDevice.h */,
29432942
84A8891B28DBD28900C51DFD /* SentryDevice.m */,
2944-
844EDC6D294143B900C86F34 /* SentryNSProcessInfoWrapper.h */,
2945-
844EDC6E294143B900C86F34 /* SentryNSProcessInfoWrapper.mm */,
29462943
844EDC74294144DB00C86F34 /* SentrySystemWrapper.h */,
29472944
844EDC75294144DB00C86F34 /* SentrySystemWrapper.mm */,
29482945
FAB359972E05D7E90083D5E3 /* SentryEventSwiftHelper.h */,
@@ -5011,7 +5008,6 @@
50115008
630436101EC0600A00C4D3FA /* SentrySerializable.h in Headers */,
50125009
63FE70DD20DA4C1000CDBAE8 /* SentryCrashMonitor_Signal.h in Headers */,
50135010
63FE710320DA4C1000CDBAE8 /* SentryCrashMachineContext_Apple.h in Headers */,
5014-
844EDC6F294143B900C86F34 /* SentryNSProcessInfoWrapper.h in Headers */,
50155011
D8479328278873A100BE8E99 /* SentryByteCountFormatter.h in Headers */,
50165012
928207C42E251B8F009285A4 /* SentryScope+PrivateSwift.h in Headers */,
50175013
63AA76981EB9C1C200D153DE /* SentryClient.h in Headers */,
@@ -5698,6 +5694,7 @@
56985694
7BE912AD272162D900E49E62 /* SentryNoOpSpan.m in Sources */,
56995695
63FE710D20DA4C1000CDBAE8 /* SentryCrashStackCursor_MachineContext.c in Sources */,
57005696
63FE70E120DA4C1000CDBAE8 /* SentryCrashMonitor_CPPException.cpp in Sources */,
5697+
FA458CC32E691A730061B13D /* SentryProcessInfo.swift in Sources */,
57015698
D8F6A2472885512100320515 /* SentryPredicateDescriptor.m in Sources */,
57025699
A839D89A24864BA8003B7AFD /* SentrySystemEventBreadcrumbs.m in Sources */,
57035700
84A305582BC9EF8C00D84283 /* SentryTraceProfiler.mm in Sources */,
@@ -5858,7 +5855,6 @@
58585855
92ECD73E2E05AD320063EC10 /* SentryLogLevel.swift in Sources */,
58595856
92ECD7402E05AD580063EC10 /* SentryLogAttribute.swift in Sources */,
58605857
7BAF3DCE243DCBFE008A5414 /* SentryTransportFactory.m in Sources */,
5861-
844EDC70294143B900C86F34 /* SentryNSProcessInfoWrapper.mm in Sources */,
58625858
F4E3DCCB2E1579240093CB80 /* SentryScopePersistentStore.swift in Sources */,
58635859
7D65260E237F649E00113EA2 /* SentryScope.m in Sources */,
58645860
D4EDF9842D0B2A210071E7B3 /* Data+SentryTracing.swift in Sources */,

SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#import "SentryHub+Private.h"
4343
#import "SentryHub+Test.h"
4444
#import "SentryLogC.h"
45-
#import "SentryNSProcessInfoWrapper.h"
4645
#import "SentryNetworkTracker.h"
4746
#import "SentryPerformanceTracker+Testing.h"
4847
#import "SentryReachability.h"
Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
import Sentry
1+
@_spi(Private) import Sentry
22

3-
public class TestSentryNSProcessInfoWrapper: SentryNSProcessInfoWrapper {
3+
@_spi(Private) public final class MockSentryProcessInfo: SentryProcessInfoSource {
4+
5+
public init() { }
6+
47
public struct Override {
5-
public var processorCount: UInt?
8+
public var processorCount: Int?
69
public var processDirectoryPath: String?
10+
public var processPath: String?
711
public var thermalState: ProcessInfo.ThermalState?
812
public var environment: [String: String]?
913
public var isiOSAppOnMac: Bool?
@@ -12,29 +16,33 @@ public class TestSentryNSProcessInfoWrapper: SentryNSProcessInfoWrapper {
1216

1317
public var overrides = Override()
1418

15-
public override var processorCount: UInt {
16-
overrides.processorCount ?? super.processorCount
19+
public var processorCount: Int {
20+
overrides.processorCount ?? ProcessInfo.processInfo.processorCount
1721
}
1822

19-
public override var processDirectoryPath: String {
20-
overrides.processDirectoryPath ?? super.processDirectoryPath
23+
public var processDirectoryPath: String {
24+
overrides.processDirectoryPath ?? ProcessInfo.processInfo.processDirectoryPath
25+
}
26+
27+
public var processPath: String? {
28+
overrides.processPath ?? ProcessInfo.processInfo.processPath
2129
}
2230

23-
public override var thermalState: ProcessInfo.ThermalState {
24-
overrides.thermalState ?? super.thermalState
31+
public var thermalState: ProcessInfo.ThermalState {
32+
overrides.thermalState ?? ProcessInfo.processInfo.thermalState
2533
}
2634

27-
public override var environment: [String: String] {
28-
overrides.environment ?? super.environment
35+
public var environment: [String: String] {
36+
overrides.environment ?? ProcessInfo.processInfo.environment
2937
}
3038

3139
@available(iOS 14.0, macOS 11.0, tvOS 14.0, *)
32-
public override var isiOSAppOnMac: Bool {
33-
return overrides.isiOSAppOnMac ?? super.isiOSAppOnMac
40+
public var isiOSAppOnMac: Bool {
41+
return overrides.isiOSAppOnMac ?? ProcessInfo.processInfo.isiOSAppOnMac
3442
}
3543

3644
@available(iOS 13.0, macOS 10.15, tvOS 13.0, *)
37-
public override var isMacCatalystApp: Bool {
38-
return overrides.isMacCatalystApp ?? super.isMacCatalystApp
45+
public var isMacCatalystApp: Bool {
46+
return overrides.isMacCatalystApp ?? ProcessInfo.processInfo.isMacCatalystApp
3947
}
4048
}

Sources/Sentry/SentryCoreDataTracker.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#import "SentryHub+Private.h"
55
#import "SentryInternalDefines.h"
66
#import "SentryLogC.h"
7-
#import "SentryNSProcessInfoWrapper.h"
87
#import "SentryPredicateDescriptor.h"
98
#import "SentrySDK+Private.h"
109
#import "SentryScope+Private.h"
@@ -19,11 +18,11 @@
1918
@implementation SentryCoreDataTracker {
2019
SentryPredicateDescriptor *predicateDescriptor;
2120
SentryThreadInspector *_threadInspector;
22-
SentryNSProcessInfoWrapper *_processInfoWrapper;
21+
id<SentryProcessInfoSource> _processInfoWrapper;
2322
}
2423

2524
- (instancetype)initWithThreadInspector:(SentryThreadInspector *)threadInspector
26-
processInfoWrapper:(SentryNSProcessInfoWrapper *)processInfoWrapper;
25+
processInfoWrapper:(id<SentryProcessInfoSource>)processInfoWrapper;
2726
{
2827
if (self = [super init]) {
2928
predicateDescriptor = [[SentryPredicateDescriptor alloc] init];

Sources/Sentry/SentryCoreDataTrackingIntegration.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#import "SentryDependencyContainer.h"
55
#import "SentryLogC.h"
66
#import "SentryNSDataSwizzling.h"
7-
#import "SentryNSProcessInfoWrapper.h"
87
#import "SentryOptions.h"
98
#import "SentryThreadInspector.h"
109

Sources/Sentry/SentryCrashWrapper.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#import "SentryCrashIntegration.h"
55
#import "SentryCrashMonitor_AppState.h"
66
#import "SentryCrashMonitor_System.h"
7-
#import "SentryNSProcessInfoWrapper.h"
87
#import "SentryScope+PrivateSwift.h"
98
#import "SentryScope.h"
109
#import "SentrySwift.h"

Sources/Sentry/SentryDependencyContainer.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#import "SentryInternalCDefines.h"
1010
#import "SentryInternalDefines.h"
1111
#import "SentryLogC.h"
12-
#import "SentryNSProcessInfoWrapper.h"
1312
#import "SentryOptions+Private.h"
1413
#import "SentrySDK+Private.h"
1514
#import "SentrySessionTracker.h"
@@ -168,7 +167,7 @@ - (instancetype)init
168167
_application = [[SentryNSApplication alloc] init];
169168
#endif // SENTRY_HAS_UIKIT
170169

171-
_processInfoWrapper = [[SentryNSProcessInfoWrapper alloc] init];
170+
_processInfoWrapper = NSProcessInfo.processInfo;
172171
_extraContextProvider = [[SentryExtraContextProvider alloc]
173172
initWithCrashWrapper:[SentryCrashWrapper sharedInstance]
174173
processInfoWrapper:_processInfoWrapper
@@ -351,7 +350,9 @@ - (SentrySwizzleWrapper *)swizzleWrapper SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_
351350
#if SENTRY_TARGET_PROFILING_SUPPORTED
352351
- (SentrySystemWrapper *)systemWrapper SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK
353352
{
354-
SENTRY_LAZY_INIT(_systemWrapper, [[SentrySystemWrapper alloc] init]);
353+
SENTRY_LAZY_INIT(_systemWrapper,
354+
[[SentrySystemWrapper alloc]
355+
initWithProcessorCount:self.processInfoWrapper.processorCount]);
355356
}
356357
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
357358

Sources/Sentry/SentryExtraContextProvider.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
#endif
66

77
@class SentryCrashWrapper;
8-
@class SentryNSProcessInfoWrapper;
98
@protocol SentryUIDeviceWrapper;
9+
@protocol SentryProcessInfoSource;
1010

1111
NS_ASSUME_NONNULL_BEGIN
1212

@@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
1717
SENTRY_NO_INIT
1818

1919
- (instancetype)initWithCrashWrapper:(SentryCrashWrapper *)crashWrapper
20-
processInfoWrapper:(SentryNSProcessInfoWrapper *)processInfoWrapper
20+
processInfoWrapper:(id<SentryProcessInfoSource>)processInfoWrapper
2121
#if TARGET_OS_IOS && SENTRY_HAS_UIKIT
2222
deviceWrapper:(id<SentryUIDeviceWrapper>)deviceWrapper
2323
#endif // TARGET_OS_IOS && SENTRY_HAS_UIKIT

Sources/Sentry/SentryExtraContextProvider.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#import "SentryCrashIntegration.h"
33
#import "SentryCrashWrapper.h"
44
#import "SentryLogC.h"
5-
#import "SentryNSProcessInfoWrapper.h"
65
#import "SentrySwift.h"
76

87
NSString *const kSentryProcessInfoThermalStateNominal = @"nominal";
@@ -13,7 +12,7 @@
1312
@interface SentryExtraContextProvider ()
1413

1514
@property (nonatomic, strong) SentryCrashWrapper *crashWrapper;
16-
@property (nonatomic, strong) SentryNSProcessInfoWrapper *processInfoWrapper;
15+
@property (nonatomic, strong) id<SentryProcessInfoSource> processInfoWrapper;
1716

1817
#if TARGET_OS_IOS && SENTRY_HAS_UIKIT
1918
@property (nonatomic, strong) id<SentryUIDeviceWrapper> deviceWrapper;

Sources/Sentry/SentryFileIOTracker.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#import "SentryHub+Private.h"
88
#import "SentryInternalDefines.h"
99
#import "SentryLogC.h"
10-
#import "SentryNSProcessInfoWrapper.h"
1110
#import "SentryOptions.h"
1211
#import "SentrySDK+Private.h"
1312
#import "SentryScope+Private.h"
@@ -26,7 +25,7 @@ @interface SentryFileIOTracker ()
2625
@property (nonatomic, assign) BOOL isEnabled;
2726
@property (nonatomic, strong) NSMutableSet<NSData *> *processingData;
2827
@property (nonatomic, strong) SentryThreadInspector *threadInspector;
29-
@property (nonatomic, strong) SentryNSProcessInfoWrapper *processInfoWrapper;
28+
@property (nonatomic, strong) id<SentryProcessInfoSource> processInfoWrapper;
3029

3130
@end
3231

@@ -46,7 +45,7 @@ + (instancetype _Nullable)sharedInstance
4645
}
4746

4847
- (instancetype)initWithThreadInspector:(SentryThreadInspector *)threadInspector
49-
processInfoWrapper:(SentryNSProcessInfoWrapper *)processInfoWrapper
48+
processInfoWrapper:(id<SentryProcessInfoSource>)processInfoWrapper
5049
{
5150
if (self = [super init]) {
5251
_processInfoWrapper = processInfoWrapper;

0 commit comments

Comments
 (0)