Skip to content

Commit f79ec31

Browse files
fix: Remove categories functions that are striped of static library (#3764)
Remove categories functions that are striped of static library Co-authored-by: Philipp Hofmann <[email protected]>
1 parent 6bc31df commit f79ec31

File tree

61 files changed

+256
-304
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+256
-304
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Unreleased
4+
5+
- Fix runtime error when including Sentry as a static lib (#3764)
6+
37
## 8.22.1
48

59
### Fixes

Sentry.xcodeproj/project.pbxproj

Lines changed: 24 additions & 32 deletions
Large diffs are not rendered by default.
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
#import "NSArray+SentrySanitize.h"
2-
#import "NSDate+SentryExtras.h"
3-
#import "NSDictionary+SentrySanitize.h"
2+
#import "SentryDateUtils.h"
3+
#import "SentryNSDictionarySanitize.h"
44

5-
@implementation
6-
NSArray (SentrySanitize)
5+
@implementation SentryArray
76

8-
- (NSArray *)sentry_sanitize
7+
+ (NSArray *)sanitizeArray:(NSArray *)array;
98
{
10-
NSMutableArray *array = [NSMutableArray array];
11-
for (id rawValue in self) {
12-
9+
NSMutableArray *result = [NSMutableArray array];
10+
for (id rawValue in array) {
1311
if ([rawValue isKindOfClass:NSString.class]) {
14-
[array addObject:rawValue];
12+
[result addObject:rawValue];
1513
} else if ([rawValue isKindOfClass:NSNumber.class]) {
16-
[array addObject:rawValue];
14+
[result addObject:rawValue];
1715
} else if ([rawValue isKindOfClass:NSDictionary.class]) {
18-
[array addObject:[(NSDictionary *)rawValue sentry_sanitize]];
16+
[result addObject:sentry_sanitize((NSDictionary *)rawValue)];
1917
} else if ([rawValue isKindOfClass:NSArray.class]) {
20-
[array addObject:[(NSArray *)rawValue sentry_sanitize]];
18+
[result addObject:[SentryArray sanitizeArray:rawValue]];
2119
} else if ([rawValue isKindOfClass:NSDate.class]) {
22-
[array addObject:[(NSDate *)rawValue sentry_toIso8601String]];
20+
NSDate *date = (NSDate *)rawValue;
21+
[result addObject:sentry_toIso8601String(date)];
2322
} else {
24-
[array addObject:[rawValue description]];
23+
[result addObject:[rawValue description]];
2524
}
2625
}
27-
return array;
26+
return result;
2827
}
2928

3029
@end

Sources/Sentry/NSData+Sentry.m

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

Sources/Sentry/NSLocale+Sentry.m

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#import "NSLocale+Sentry.h"
22

3-
@implementation
4-
NSLocale (Sentry)
3+
@implementation SentryLocale
54

6-
- (BOOL)sentry_timeIs24HourFormat
5+
+ (BOOL)timeIs24HourFormat
76
{
87
NSDateFormatter *formatter = [NSDateFormatter new];
98
[formatter setDateStyle:NSDateFormatterNoStyle];

Sources/Sentry/NSMutableDictionary+Sentry.m

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
#import "NSMutableDictionary+Sentry.h"
22

3-
@implementation
4-
NSMutableDictionary (Sentry)
3+
@implementation SentryDictionary
54

6-
- (void)mergeEntriesFromDictionary:(NSDictionary *)otherDictionary
5+
+ (void)mergeEntriesFromDictionary:(NSDictionary *)dictionary
6+
intoDictionary:(NSMutableDictionary *)destination
77
{
8-
[otherDictionary enumerateKeysAndObjectsUsingBlock:^(id otherKey, id otherObj, BOOL *stop) {
8+
[dictionary enumerateKeysAndObjectsUsingBlock:^(id otherKey, id otherObj, BOOL *stop) {
99
if ([otherObj isKindOfClass:NSDictionary.class] &&
10-
[self[otherKey] isKindOfClass:NSDictionary.class]) {
11-
NSMutableDictionary *mergedDict = ((NSDictionary *)self[otherKey]).mutableCopy;
12-
[mergedDict mergeEntriesFromDictionary:(NSDictionary *)otherObj];
13-
self[otherKey] = mergedDict;
10+
[destination[otherKey] isKindOfClass:NSDictionary.class]) {
11+
NSMutableDictionary *mergedDict = ((NSDictionary *)destination[otherKey]).mutableCopy;
12+
[SentryDictionary mergeEntriesFromDictionary:otherObj intoDictionary:mergedDict];
13+
destination[otherKey] = mergedDict;
1414
return;
1515
}
1616

17-
self[otherKey] = otherObj;
17+
destination[otherKey] = otherObj;
1818
}];
1919
}
2020

21-
- (void)setBoolValue:(nullable NSNumber *)value forKey:(NSString *)key
21+
+ (void)setBoolValue:(nullable NSNumber *)value
22+
forKey:(NSString *)key
23+
intoDictionary:(NSMutableDictionary *)destination
2224
{
2325
if (value != nil) {
24-
[self setValue:@([value boolValue]) forKey:key];
26+
[destination setValue:@([value boolValue]) forKey:key];
2527
}
2628
}
2729

Sources/Sentry/SentryAppStartMeasurement.m

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

33
#if SENTRY_UIKIT_AVAILABLE
44

5-
# import "NSDate+SentryExtras.h"
5+
# import "SentryDateUtils.h"
66
# import "SentryLog.h"
77
# import <Foundation/Foundation.h>
88

Sources/Sentry/SentryAppState.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#import <NSDate+SentryExtras.h>
21
#import <SentryAppState.h>
2+
#import <SentryDateUtils.h>
33

44
NS_ASSUME_NONNULL_BEGIN
55

@@ -64,7 +64,7 @@ - (nullable instancetype)initWithJSONObject:(NSDictionary *)jsonObject
6464
id systemBoot = [jsonObject valueForKey:@"system_boot_timestamp"];
6565
if (systemBoot == nil || ![systemBoot isKindOfClass:[NSString class]])
6666
return nil;
67-
NSDate *systemBootTimestamp = [NSDate sentry_fromIso8601String:systemBoot];
67+
NSDate *systemBootTimestamp = sentry_fromIso8601String(systemBoot);
6868
if (nil == systemBootTimestamp) {
6969
return nil;
7070
}
@@ -111,7 +111,7 @@ - (nullable instancetype)initWithJSONObject:(NSDictionary *)jsonObject
111111
[data setValue:self.osVersion forKey:@"os_version"];
112112
[data setValue:self.vendorId forKey:@"vendor_id"];
113113
[data setValue:@(self.isDebugging) forKey:@"is_debugging"];
114-
[data setValue:[self.systemBootTimestamp sentry_toIso8601String]
114+
[data setValue:sentry_toIso8601String(self.systemBootTimestamp)
115115
forKey:@"system_boot_timestamp"];
116116
[data setValue:@(self.isActive) forKey:@"is_active"];
117117
[data setValue:@(self.wasTerminated) forKey:@"was_terminated"];

Sources/Sentry/SentryBreadcrumb.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#import "SentryBreadcrumb.h"
2-
#import "NSDate+SentryExtras.h"
3-
#import "NSDictionary+SentrySanitize.h"
2+
#import "SentryDateUtils.h"
43
#import "SentryLevelMapper.h"
4+
#import "SentryNSDictionarySanitize.h"
55

66
@interface
77
SentryBreadcrumb ()
@@ -25,7 +25,7 @@ - (instancetype)initWithDictionary:(NSDictionary *)dictionary
2525
if ([key isEqualToString:@"level"] && isString) {
2626
self.level = sentryLevelForString(value);
2727
} else if ([key isEqualToString:@"timestamp"] && isString) {
28-
self.timestamp = [NSDate sentry_fromIso8601String:value];
28+
self.timestamp = sentry_fromIso8601String(value);
2929
} else if ([key isEqualToString:@"category"] && isString) {
3030
self.category = value;
3131
} else if ([key isEqualToString:@"type"] && isString) {
@@ -66,11 +66,11 @@ - (instancetype)init
6666
NSMutableDictionary *serializedData = [NSMutableDictionary new];
6767

6868
[serializedData setValue:nameForSentryLevel(self.level) forKey:@"level"];
69-
[serializedData setValue:[self.timestamp sentry_toIso8601String] forKey:@"timestamp"];
69+
[serializedData setValue:sentry_toIso8601String(self.timestamp) forKey:@"timestamp"];
7070
[serializedData setValue:self.category forKey:@"category"];
7171
[serializedData setValue:self.type forKey:@"type"];
7272
[serializedData setValue:self.message forKey:@"message"];
73-
[serializedData setValue:[self.data sentry_sanitize] forKey:@"data"];
73+
[serializedData setValue:sentry_sanitize(self.data) forKey:@"data"];
7474
NSDictionary<NSString *, id> *unknown = self.unknown;
7575
if (unknown != nil) {
7676
for (id key in unknown) {

Sources/Sentry/SentryClient.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#import "SentryClient.h"
2-
#import "NSDictionary+SentrySanitize.h"
32
#import "NSLocale+Sentry.h"
43
#import "SentryAppState.h"
54
#import "SentryAppStateManager.h"
@@ -28,6 +27,7 @@
2827
#import "SentryMechanismMeta.h"
2928
#import "SentryMessage.h"
3029
#import "SentryMeta.h"
30+
#import "SentryNSDictionarySanitize.h"
3131
#import "SentryNSError.h"
3232
#import "SentryOptions+Private.h"
3333
#import "SentryPropagationContext.h"
@@ -260,7 +260,7 @@ - (SentryEvent *)buildErrorEvent:(NSError *)error
260260

261261
// Once the UI displays the mechanism data we can the userInfo from the event.context using only
262262
// the root error's userInfo.
263-
[self setUserInfo:[error.userInfo sentry_sanitize] withEvent:event];
263+
[self setUserInfo:sentry_sanitize(error.userInfo) withEvent:event];
264264

265265
return event;
266266
}
@@ -302,7 +302,7 @@ - (SentryException *)exceptionForError:(NSError *)error
302302
// use a simple enum.
303303
mechanism.desc = error.description;
304304

305-
NSDictionary<NSString *, id> *userInfo = [error.userInfo sentry_sanitize];
305+
NSDictionary<NSString *, id> *userInfo = sentry_sanitize(error.userInfo);
306306
mechanism.data = userInfo;
307307
exception.mechanism = mechanism;
308308

@@ -743,7 +743,7 @@ - (void)setUserInfo:(NSDictionary *)userInfo withEvent:(SentryEvent *)event
743743
context = [event.context mutableCopy];
744744
}
745745

746-
[context setValue:[userInfo sentry_sanitize] forKey:@"user info"];
746+
[context setValue:sentry_sanitize(userInfo) forKey:@"user info"];
747747
}
748748
}
749749

@@ -794,7 +794,7 @@ - (void)applyCultureContextToEvent:(SentryEvent *)event
794794
}
795795
#endif
796796
culture[@"locale"] = self.locale.localeIdentifier;
797-
culture[@"is_24_hour_format"] = @(self.locale.sentry_timeIs24HourFormat);
797+
culture[@"is_24_hour_format"] = @([SentryLocale timeIs24HourFormat]);
798798
culture[@"timezone"] = self.timezone.name;
799799
}];
800800
}

Sources/Sentry/SentryCrashReportConverter.m

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#import "SentryCrashReportConverter.h"
2-
#import "NSDate+SentryExtras.h"
32
#import "SentryBreadcrumb.h"
43
#import "SentryCrashStackCursor.h"
4+
#import "SentryDateUtils.h"
55
#import "SentryDebugMeta.h"
66
#import "SentryEvent.h"
77
#import "SentryException.h"
@@ -104,8 +104,7 @@ - (SentryEvent *_Nullable)convertReportToEvent
104104
event.timestamp = [NSDate
105105
dateWithTimeIntervalSince1970:[self.report[@"report"][@"timestamp"] integerValue]];
106106
} else {
107-
event.timestamp =
108-
[NSDate sentry_fromIso8601String:self.report[@"report"][@"timestamp"]];
107+
event.timestamp = sentry_fromIso8601String(self.report[@"report"][@"timestamp"]);
109108
}
110109
event.threads = [self convertThreads];
111110
event.debugMeta = [self debugMetaForThreads:event.threads];
@@ -172,7 +171,7 @@ - (SentryUser *_Nullable)convertUser
172171
category:storedCrumb[@"category"]];
173172
crumb.message = storedCrumb[@"message"];
174173
crumb.type = storedCrumb[@"type"];
175-
crumb.timestamp = [NSDate sentry_fromIso8601String:storedCrumb[@"timestamp"]];
174+
crumb.timestamp = sentry_fromIso8601String(storedCrumb[@"timestamp"]);
176175
crumb.data = storedCrumb[@"data"];
177176
[breadcrumbs addObject:crumb];
178177
}

Sources/Sentry/SentryCrashScopeObserver.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#import "SentryLevelMapper.h"
22
#import <Foundation/Foundation.h>
3-
#import <NSData+Sentry.h>
43
#import <SentryBreadcrumb.h>
54
#import <SentryCrashJSONCodec.h>
65
#import <SentryCrashJSONCodecObjC.h>
76
#import <SentryCrashScopeObserver.h>
87
#import <SentryLog.h>
8+
#import <SentryNSDataUtils.h>
99
#import <SentryScopeSyncC.h>
1010
#import <SentryUser.h>
1111

@@ -156,7 +156,7 @@ - (nullable NSData *)toJSONEncodedCString:(id)toSerialize
156156
}
157157

158158
// C strings need to be null terminated
159-
return [json sentry_nullTerminated];
159+
return sentry_nullTerminated(json);
160160
}
161161

162162
@end

Sources/Sentry/NSDate+SentryExtras.m renamed to Sources/Sentry/SentryDateUtils.m

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
#import "NSDate+SentryExtras.h"
1+
#import "SentryDateUtils.h"
22

33
NS_ASSUME_NONNULL_BEGIN
44

5-
@implementation
6-
NSDate (SentryExtras)
7-
8-
+ (NSDateFormatter *)getIso8601Formatter
5+
NSDateFormatter *
6+
sentryGetIso8601Formatter(void)
97
{
108
static NSDateFormatter *isoFormatter = nil;
119
static dispatch_once_t onceToken;
@@ -29,7 +27,8 @@ + (NSDateFormatter *)getIso8601Formatter
2927
* nanoseconds to the output of NSDateFormatter please use a numeric float instead, which can be
3028
* retrieved with timeIntervalSince1970.
3129
*/
32-
+ (NSDateFormatter *)getIso8601FormatterWithMillisecondPrecision
30+
NSDateFormatter *
31+
sentryGetIso8601FormatterWithMillisecondPrecision(void)
3332
{
3433
static NSDateFormatter *isoFormatter = nil;
3534
static dispatch_once_t onceToken;
@@ -43,12 +42,13 @@ + (NSDateFormatter *)getIso8601FormatterWithMillisecondPrecision
4342
return isoFormatter;
4443
}
4544

46-
+ (NSDate *)sentry_fromIso8601String:(NSString *)string
45+
NSDate *
46+
sentry_fromIso8601String(NSString *string)
4747
{
48-
NSDate *date = [[self.class getIso8601FormatterWithMillisecondPrecision] dateFromString:string];
48+
NSDate *date = [sentryGetIso8601FormatterWithMillisecondPrecision() dateFromString:string];
4949
if (nil == date) {
5050
// Parse date with low precision formatter for backward compatible
51-
return [[self.class getIso8601Formatter] dateFromString:string];
51+
return [sentryGetIso8601Formatter() dateFromString:string];
5252
} else {
5353
return date;
5454
}
@@ -58,11 +58,11 @@ + (NSDate *)sentry_fromIso8601String:(NSString *)string
5858
* Only works with milliseconds precision. For more details see
5959
* getIso8601FormatterWithMillisecondPrecision.
6060
*/
61-
- (NSString *)sentry_toIso8601String
61+
NSString *
62+
sentry_toIso8601String(NSDate *date)
6263
{
63-
return [[self.class getIso8601FormatterWithMillisecondPrecision] stringFromDate:self];
64+
NSDateFormatter *formatter = sentryGetIso8601FormatterWithMillisecondPrecision();
65+
return [formatter stringFromDate:date];
6466
}
6567

66-
@end
67-
6868
NS_ASSUME_NONNULL_END

Sources/Sentry/SentryEvent.m

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#import "NSDate+SentryExtras.h"
2-
#import "NSDictionary+SentrySanitize.h"
31
#import "SentryANRTrackingIntegration.h"
42
#import "SentryBreadcrumb.h"
53
#import "SentryClient.h"
@@ -11,6 +9,7 @@
119
#import "SentryLevelMapper.h"
1210
#import "SentryMessage.h"
1311
#import "SentryMeta.h"
12+
#import "SentryNSDictionarySanitize.h"
1413
#import "SentryRequest.h"
1514
#import "SentryStacktrace.h"
1615
#import "SentrySwift.h"
@@ -72,7 +71,7 @@ - (instancetype)initWithError:(NSError *)error
7271

7372
// This is important here, since we probably use __sentry internal extras
7473
// before
75-
[serializedData setValue:[self.extra sentry_sanitize] forKey:@"extra"];
74+
[serializedData setValue:sentry_sanitize(self.extra) forKey:@"extra"];
7675
[serializedData setValue:self.tags forKey:@"tags"];
7776

7877
return serializedData;
@@ -120,7 +119,7 @@ - (void)addThreads:(NSMutableDictionary *)serializedData
120119

121120
- (void)addSimpleProperties:(NSMutableDictionary *)serializedData
122121
{
123-
[serializedData setValue:[self.sdk sentry_sanitize] forKey:@"sdk"];
122+
[serializedData setValue:sentry_sanitize(self.sdk) forKey:@"sdk"];
124123
[serializedData setValue:self.releaseName forKey:@"release"];
125124
[serializedData setValue:self.dist forKey:@"dist"];
126125
[serializedData setValue:self.environment forKey:@"environment"];
@@ -144,7 +143,7 @@ - (void)addSimpleProperties:(NSMutableDictionary *)serializedData
144143
[serializedData setValue:breadcrumbs forKey:@"breadcrumbs"];
145144
}
146145

147-
[serializedData setValue:[self.context sentry_sanitize] forKey:@"contexts"];
146+
[serializedData setValue:sentry_sanitize(self.context) forKey:@"contexts"];
148147

149148
if (nil != self.message) {
150149
[serializedData setValue:[self.message serialize] forKey:@"message"];

0 commit comments

Comments
 (0)