Skip to content

Commit df9b912

Browse files
antonisclaude
andcommitted
fix(ios): Set screenshot options via properties instead of init(dictionary:)
The SentryViewScreenshotOptions.init(dictionary:) convenience initializer is internal (not @objc exposed) and not accessible from Objective-C. Set properties directly on the default instance instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5cc659b commit df9b912

1 file changed

Lines changed: 34 additions & 2 deletions

File tree

packages/core/ios/RNSentryStart.m

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,40 @@ + (SentryOptions *_Nullable)createOptionsWithDictionary:(NSDictionary *_Nonnull)
5858
#if SENTRY_HAS_UIKIT
5959
NSDictionary *screenshotDict = mutableOptions[@"screenshot"];
6060
if ([screenshotDict isKindOfClass:[NSDictionary class]]) {
61-
sentryOptions.screenshot =
62-
[[SentryViewScreenshotOptions alloc] initWithDictionary:screenshotDict];
61+
id maskAllText = screenshotDict[@"maskAllText"];
62+
if ([maskAllText isKindOfClass:[NSNumber class]]) {
63+
sentryOptions.screenshot.maskAllText = [maskAllText boolValue];
64+
}
65+
id maskAllImages = screenshotDict[@"maskAllImages"];
66+
if ([maskAllImages isKindOfClass:[NSNumber class]]) {
67+
sentryOptions.screenshot.maskAllImages = [maskAllImages boolValue];
68+
}
69+
id maskedViewClasses = screenshotDict[@"maskedViewClasses"];
70+
if ([maskedViewClasses isKindOfClass:[NSArray class]]) {
71+
NSMutableArray *classes = [NSMutableArray array];
72+
for (id className in maskedViewClasses) {
73+
if ([className isKindOfClass:[NSString class]]) {
74+
Class cls = NSClassFromString(className);
75+
if (cls != nil) {
76+
[classes addObject:cls];
77+
}
78+
}
79+
}
80+
sentryOptions.screenshot.maskedViewClasses = classes;
81+
}
82+
id unmaskedViewClasses = screenshotDict[@"unmaskedViewClasses"];
83+
if ([unmaskedViewClasses isKindOfClass:[NSArray class]]) {
84+
NSMutableArray *classes = [NSMutableArray array];
85+
for (id className in unmaskedViewClasses) {
86+
if ([className isKindOfClass:[NSString class]]) {
87+
Class cls = NSClassFromString(className);
88+
if (cls != nil) {
89+
[classes addObject:cls];
90+
}
91+
}
92+
}
93+
sentryOptions.screenshot.unmaskedViewClasses = classes;
94+
}
6395
}
6496
#endif
6597

0 commit comments

Comments
 (0)