diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b9cfe2699..0824009197 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ ### Changed +- (react-native): Update bugsnag-cocoa to v6.9.0 + - App hangs that occur while an app is in the background will no longer be reported. [bugsnag-cocoa#1075](https://github.com/bugsnag/bugsnag-cocoa/pull/1075) + - Add `binaryArch` and `runningOnRosetta` to the `app` metadata tab. [bugsnag-cocoa#1073](https://github.com/bugsnag/bugsnag-cocoa/pull/1073) + - Bugsnag can now be used without AppKit, allowing use in daemons and other processes running in non-UI sessions. [bugsnag-cocoa#1072](https://github.com/bugsnag/bugsnag-cocoa/pull/1072) - (react-native): Update bugsnag-android to v5.9.1 - Add projectPackages field to error payloads [bugsnag-android#1226](https://github.com/bugsnag/bugsnag-android/pull/1226) - Fix deserialization bug in persisted NDK errors [bugsnag-android#1220](https://github.com/bugsnag/bugsnag-android/pull/1220) diff --git a/packages/react-native/ios/.bugsnag-cocoa-version b/packages/react-native/ios/.bugsnag-cocoa-version index fb3d503f98..ebde1cf6d9 100644 --- a/packages/react-native/ios/.bugsnag-cocoa-version +++ b/packages/react-native/ios/.bugsnag-cocoa-version @@ -1 +1 @@ -5a002460e6a1bc0e51505709c7194a35ac340048 +2f5925e6d61217901e8b6e25f9f146aa9f9d3fa1 diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json index 3a8bc612aa..31fc8c4c46 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json @@ -1,6 +1,6 @@ { "name": "Bugsnag", - "version": "6.8.4", + "version": "6.9.0", "summary": "The Bugsnag crash reporting framework for Apple platforms.", "homepage": "https://bugsnag.com", "license": "MIT", @@ -9,7 +9,7 @@ }, "source": { "git": "https://github.com/bugsnag/bugsnag-cocoa.git", - "tag": "v6.8.4" + "tag": "v6.9.0" }, "frameworks": [ "Foundation", diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj index 6b9b82173b..4d14f9cfd4 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj @@ -680,6 +680,7 @@ 01840B7425DC26E200F95648 /* BSGEventUploader.m in Sources */ = {isa = PBXBuildFile; fileRef = 01840B6E25DC26E200F95648 /* BSGEventUploader.m */; }; 01840B7525DC26E200F95648 /* BSGEventUploader.m in Sources */ = {isa = PBXBuildFile; fileRef = 01840B6E25DC26E200F95648 /* BSGEventUploader.m */; }; 0187D464255BD7B800C503D9 /* BugsnagApiClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CB9103632502320A00E9D1E2 /* BugsnagApiClientTest.m */; }; + 019480D42625F3EB00E833ED /* BSGAppKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 019480D32625F3EB00E833ED /* BSGAppKitTests.m */; }; 01B14C56251CE55F00118748 /* report-react-native-promise-rejection.json in Resources */ = {isa = PBXBuildFile; fileRef = 01B14C55251CE55F00118748 /* report-react-native-promise-rejection.json */; }; 01B14C57251CE55F00118748 /* report-react-native-promise-rejection.json in Resources */ = {isa = PBXBuildFile; fileRef = 01B14C55251CE55F00118748 /* report-react-native-promise-rejection.json */; }; 01B14C58251CE55F00118748 /* report-react-native-promise-rejection.json in Resources */ = {isa = PBXBuildFile; fileRef = 01B14C55251CE55F00118748 /* report-react-native-promise-rejection.json */; }; @@ -1317,12 +1318,15 @@ 0163BF5825823D8D008DC28B /* NotificationBreadcrumbTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NotificationBreadcrumbTests.m; sourceTree = ""; }; 016875C4258D003200DFFF69 /* NSUserDefaultsStub.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSUserDefaultsStub.h; sourceTree = ""; }; 016875C5258D003200DFFF69 /* NSUserDefaultsStub.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NSUserDefaultsStub.m; sourceTree = ""; }; + 017824BD262D65A000D18AFA /* Bugsnag.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Bugsnag.xcconfig; sourceTree = ""; }; 01840B6D25DC26E200F95648 /* BSGEventUploader.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BSGEventUploader.h; sourceTree = ""; }; 01840B6E25DC26E200F95648 /* BSGEventUploader.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BSGEventUploader.m; sourceTree = ""; }; 01937CF9257A7B4C00F2DE31 /* Bugsnag+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Bugsnag+Private.h"; sourceTree = ""; }; 01937D09257A7ED000F2DE31 /* BugsnagSessionTracker+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagSessionTracker+Private.h"; sourceTree = ""; }; 01937D11257A814D00F2DE31 /* BugsnagMetadata+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagMetadata+Private.h"; sourceTree = ""; }; 01937D2E257A83A900F2DE31 /* BugsnagApp+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagApp+Private.h"; sourceTree = ""; }; + 019480C42625EE9800E833ED /* BSGAppKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BSGAppKit.h; sourceTree = ""; }; + 019480D32625F3EB00E833ED /* BSGAppKitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BSGAppKitTests.m; sourceTree = ""; }; 0195FC3B256BC81400DE6646 /* BugsnagEvent+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagEvent+Private.h"; sourceTree = ""; }; 0198762E2567D5AB000A7AF3 /* BugsnagStackframe+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagStackframe+Private.h"; sourceTree = ""; }; 01B14C55251CE55F00118748 /* report-react-native-promise-rejection.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "report-react-native-promise-rejection.json"; sourceTree = ""; }; @@ -1641,6 +1645,7 @@ 00AD1C6824869B0E00A27979 = { isa = PBXGroup; children = ( + 017824BD262D65A000D18AFA /* Bugsnag.xcconfig */, 01C2769B2601F44D006901EA /* CHANGELOG.md */, 01C2769C2601F455006901EA /* CONTRIBUTING.md */, 00E636B2248702A1006CBF1A /* README.md */, @@ -1699,6 +1704,7 @@ 00AD1C7F24869B0E00A27979 /* Tests */ = { isa = PBXGroup; children = ( + 019480D32625F3EB00E833ED /* BSGAppKitTests.m */, 00896A3F2486DBDD00DC48C2 /* BSGConfigurationBuilderTests.m */, 008966C62486D43600DC48C2 /* BSGConnectivityTest.m */, 01BDB1CE25DEBF4600A91FAF /* BSGEventUploadKSCrashReportOperationTests.m */, @@ -1831,6 +1837,7 @@ 008969142486DAD000DC48C2 /* BSG_RFC3339DateTool.m */, 010FF28225ED2A8D00E4F2B0 /* BSGAppHangDetector.h */, 010FF28325ED2A8D00E4F2B0 /* BSGAppHangDetector.m */, + 019480C42625EE9800E833ED /* BSGAppKit.h */, CBCF77A125010648004AF22A /* BSGJSONSerialization.h */, CBCF77A225010648004AF22A /* BSGJSONSerialization.m */, 008968112486DA5600DC48C2 /* BSGSerialization.h */, @@ -2838,6 +2845,7 @@ 008967132486D43700DC48C2 /* BugsnagEventTests.m in Sources */, 0089675B2486D43700DC48C2 /* BugsnagEnabledBreadcrumbTest.m in Sources */, 008966EC2486D43700DC48C2 /* BugsnagDeviceTest.m in Sources */, + 019480D42625F3EB00E833ED /* BSGAppKitTests.m in Sources */, 008967462486D43700DC48C2 /* BugsnagTests.m in Sources */, 008967A62486D43700DC48C2 /* KSString_Tests.m in Sources */, 004E353D2487B3B8007FBAE4 /* BugsnagSwiftTests.swift in Sources */, @@ -3177,6 +3185,7 @@ /* Begin XCBuildConfiguration section */ 00AD1C8424869B0E00A27979 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 017824BD262D65A000D18AFA /* Bugsnag.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; APPLICATION_EXTENSION_API_ONLY = YES; @@ -3246,12 +3255,12 @@ SDKROOT = iphoneos; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; - WARNING_CFLAGS = "-Werror=incomplete-implementation"; }; name = Debug; }; 00AD1C8524869B0E00A27979 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 017824BD262D65A000D18AFA /* Bugsnag.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; APPLICATION_EXTENSION_API_ONLY = YES; @@ -3315,7 +3324,6 @@ VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; - WARNING_CFLAGS = "-Werror=incomplete-implementation"; }; name = Release; }; @@ -3369,6 +3377,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; INFOPLIST_FILE = ./Tests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.3; LD_RUNPATH_SEARCH_PATHS = ( @@ -3388,6 +3397,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; INFOPLIST_FILE = ./Tests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.3; LD_RUNPATH_SEARCH_PATHS = ( @@ -3406,6 +3416,7 @@ 00AD1CBF24869C1200A27979 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_MODULES_AUTOLINK = NO; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; @@ -3428,6 +3439,7 @@ 00AD1CC024869C1200A27979 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_MODULES_AUTOLINK = NO; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; DEFINES_MODULE = YES; @@ -3452,6 +3464,7 @@ buildSettings = { CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; INFOPLIST_FILE = ./Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -3472,6 +3485,7 @@ buildSettings = { CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; INFOPLIST_FILE = ./Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -3535,6 +3549,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; INFOPLIST_FILE = ./Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -3555,6 +3570,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; INFOPLIST_FILE = ./Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.m index aeed4a1b4e..87c1f8c0de 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.m @@ -15,7 +15,7 @@ #if TARGET_OS_IOS || TARGET_OS_TV #import "BSGUIKit.h" #else -#import +#import "BSGAppKit.h" #endif @@ -24,7 +24,7 @@ @interface BSGNotificationBreadcrumbs () -@property NSDictionary *notificationNameMap; +@property (nonatomic) NSDictionary *notificationNameMap; @end @@ -37,7 +37,7 @@ - (instancetype)initWithConfiguration:(BugsnagConfiguration *)configuration _configuration = configuration; _notificationCenter = NSNotificationCenter.defaultCenter; #if TARGET_OS_OSX - _workspaceNotificationCenter = NSWorkspace.sharedWorkspace.notificationCenter; + _workspaceNotificationCenter = [NSWORKSPACE sharedWorkspace].notificationCenter; #endif _breadcrumbSink = breadcrumbSink; _notificationNameMap = @{ @@ -261,7 +261,7 @@ - (void)addBreadcrumbForNotification:(NSNotification *)notification { [self addBreadcrumbWithType:BSGBreadcrumbTypeState forNotificationName:notification.name]; } -- (void)addBreadcrumbForTableViewNotification:(NSNotification *)notification { +- (void)addBreadcrumbForTableViewNotification:(__attribute__((unused)) NSNotification *)notification { #if TARGET_OS_IOS || TARGET_OS_TV NSIndexPath *indexPath = ((UITableView *)notification.object).indexPathForSelectedRow; [self addBreadcrumbWithType:BSGBreadcrumbTypeNavigation forNotificationName:notification.name metadata: @@ -273,15 +273,15 @@ - (void)addBreadcrumbForTableViewNotification:(NSNotification *)notification { #endif } -- (void)addBreadcrumbForMenuItemNotification:(NSNotification *)notification { +- (void)addBreadcrumbForMenuItemNotification:(__attribute__((unused)) NSNotification *)notification { #if TARGET_OS_OSX NSMenuItem *menuItem = [[notification userInfo] valueForKey:@"MenuItem"]; [self addBreadcrumbWithType:BSGBreadcrumbTypeState forNotificationName:notification.name metadata: - [menuItem isKindOfClass:[NSMenuItem class]] ? @{BSGKeyAction : menuItem.title} : nil]; + [menuItem isKindOfClass:NSMENUITEM] ? @{BSGKeyAction : menuItem.title} : nil]; #endif } -- (void)addBreadcrumbForControlNotification:(NSNotification *)notification { +- (void)addBreadcrumbForControlNotification:(__attribute__((unused)) NSNotification *)notification { #if TARGET_OS_IOS NSString *label = ((UIControl *)notification.object).accessibilityLabel; [self addBreadcrumbWithType:BSGBreadcrumbTypeUser forNotificationName:notification.name metadata: diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.m index ce85805dcd..d622a2a124 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.m @@ -31,11 +31,11 @@ @interface BugsnagBreadcrumbs () -@property (readonly) NSString *breadcrumbsPath; +@property (readonly, nonatomic) NSString *breadcrumbsPath; -@property BugsnagConfiguration *config; -@property unsigned int nextFileNumber; -@property unsigned int maxBreadcrumbs; +@property (nonatomic) BugsnagConfiguration *config; +@property (nonatomic) unsigned int nextFileNumber; +@property (nonatomic) unsigned int maxBreadcrumbs; @end @@ -144,8 +144,8 @@ - (void)writeBreadcrumbData:(NSData *)data toFileNumber:(unsigned int)fileNumber } if (fileNumber >= self.maxBreadcrumbs) { - NSString *path = [self pathForFileNumber:fileNumber - self.maxBreadcrumbs]; - if (![[NSFileManager defaultManager] removeItemAtPath:path error:&error]) { + NSString *oldPath = [self pathForFileNumber:fileNumber - self.maxBreadcrumbs]; + if (![[NSFileManager defaultManager] removeItemAtPath:oldPath error:&error]) { bsg_log_err(@"Unable to delete old breadcrumb: %@", error); } } @@ -224,7 +224,7 @@ void BugsnagBreadcrumbsWriteCrashReport(const BSG_KSCrashReportWriter *writer) { writer->beginArray(writer, "breadcrumbs"); for (unsigned int i = g_context.firstFileNumber; i < g_context.nextFileNumber; i++) { int result = snprintf(path, sizeof(path), "%s/%u.json", g_context.directoryPath, i); - if (result < 0 || result >= sizeof(path)) { + if (result < 0 || result >= (int)sizeof(path)) { bsg_log_err(@"Breadcrumb path is too long"); continue; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Bugsnag.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Bugsnag.m index d7d71d0ccc..c054587463 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Bugsnag.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Bugsnag.m @@ -192,7 +192,7 @@ + (void)leaveBreadcrumbWithMessage:(NSString *_Nonnull)message + (NSArray *_Nonnull)breadcrumbs { if ([self bugsnagStarted]) { - return self.client.breadcrumbs.breadcrumbs; + return self.client.breadcrumbs.breadcrumbs ?: @[]; } else { return @[]; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagCrashSentry.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagCrashSentry.h index 4f3c8bac91..e138f36b30 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagCrashSentry.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagCrashSentry.h @@ -12,13 +12,9 @@ #import "BSG_KSCrashType.h" #import "BugsnagConfiguration.h" -@class BugsnagNotifier; - @interface BugsnagCrashSentry : NSObject -- (void)install:(BugsnagConfiguration *)config - notifier:(BugsnagNotifier *)notifier - onCrash:(BSGReportCallback)onCrash; +- (void)install:(BugsnagConfiguration *)config onCrash:(BSGReportCallback)onCrash; - (BSG_KSCrashType)mapKSToBSGCrashTypes:(BugsnagErrorTypes *)errorTypes; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagCrashSentry.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagCrashSentry.m index 0c43a11ea2..be960b4bbb 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagCrashSentry.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagCrashSentry.m @@ -19,9 +19,7 @@ @implementation BugsnagCrashSentry -- (void)install:(BugsnagConfiguration *)config - notifier:(BugsnagNotifier *)notifier - onCrash:(BSGReportCallback)onCrash +- (void)install:(BugsnagConfiguration *)config onCrash:(BSGReportCallback)onCrash { BSG_KSCrash *ksCrash = [BSG_KSCrash sharedInstance]; ksCrash.introspectMemory = NO; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSessionTracker+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSessionTracker+Private.h index 776444bab3..2d0572b000 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSessionTracker+Private.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSessionTracker+Private.h @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN @property (copy, nonatomic) NSString *codeBundleId; -@property (nullable) BugsnagSession *currentSession; +@property (nullable, nonatomic) BugsnagSession *currentSession; @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSessionTracker.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSessionTracker.m index dc4dc6d80e..28feab0d7a 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSessionTracker.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSessionTracker.m @@ -29,7 +29,7 @@ NSString *const BSGSessionUpdateNotification = @"BugsnagSessionChanged"; @interface BugsnagSessionTracker () -@property (weak, nonatomic) BugsnagConfiguration *config; +@property (strong, nonatomic) BugsnagConfiguration *config; @property (weak, nonatomic) BugsnagClient *client; @property (strong, nonatomic) BugsnagSessionFileStore *sessionStore; @property (strong, nonatomic) BugsnagSessionTrackingApiClient *apiClient; @@ -40,7 +40,7 @@ @interface BugsnagSessionTracker () */ @property (nonatomic, strong, readonly) SessionTrackerCallback callback; -@property NSMutableDictionary *extraRuntimeInfo; +@property (nonatomic) NSMutableDictionary *extraRuntimeInfo; @end @implementation BugsnagSessionTracker @@ -111,7 +111,7 @@ - (void)startNewSessionIfAutoCaptureEnabled { - (void)startNewSessionWithAutoCaptureValue:(BOOL)isAutoCaptured { NSSet *releaseStages = self.config.enabledReleaseStages; - if (releaseStages != nil && ![releaseStages containsObject:self.config.releaseStage]) { + if (releaseStages != nil && ![releaseStages containsObject:self.config.releaseStage ?: @""]) { return; } if (self.config.sessionURL == nil) { diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.m index 38b5db6c18..d4ce2b1e86 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.m @@ -11,7 +11,7 @@ #import "BugsnagSystemState.h" #if TARGET_OS_OSX -#import +#import "BSGAppKit.h" #else #import "BSGUIKit.h" #endif @@ -79,7 +79,7 @@ id blankIfNil(id value) { bool isActive = true; #if TARGET_OS_OSX // MacOS "active" serves the same purpose as "foreground" in iOS - isInForeground = [NSApplication sharedApplication].active; + isInForeground = [NSAPPLICATION sharedApplication].active; #else UIApplicationState appState = [BSG_KSSystemInfo currentAppState]; isInForeground = [BSG_KSSystemInfo isInForeground:appState]; @@ -171,44 +171,52 @@ - (instancetype)initWithConfiguration:(BugsnagConfiguration *)config { __weak __typeof__(self) weakSelf = self; NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; #if TARGET_OS_OSX - [center addObserverForName:NSApplicationWillTerminateNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [center addObserverForName:NSApplicationWillTerminateNotification object:nil queue:nil + usingBlock:^(__attribute__((unused)) NSNotification * _Nonnull note) { __strong __typeof__(self) strongSelf = weakSelf; [strongSelf.kvStore setBoolean:YES forKey:SYSTEMSTATE_APP_WAS_TERMINATED]; // No need to update since we are shutting down. }]; // MacOS "active" serves the same purpose as "foreground" in iOS - [center addObserverForName:NSApplicationDidBecomeActiveNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [center addObserverForName:NSApplicationDidBecomeActiveNotification object:nil queue:nil + usingBlock:^(__attribute__((unused)) NSNotification * _Nonnull note) { __strong __typeof__(self) strongSelf = weakSelf; [strongSelf.kvStore setBoolean:YES forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; [strongSelf setValue:@YES forAppKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; }]; - [center addObserverForName:NSApplicationDidResignActiveNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [center addObserverForName:NSApplicationDidResignActiveNotification object:nil queue:nil + usingBlock:^(__attribute__((unused)) NSNotification * _Nonnull note) { __strong __typeof__(self) strongSelf = weakSelf; [strongSelf.kvStore setBoolean:NO forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; [strongSelf setValue:@NO forAppKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; }]; #else - [center addObserverForName:UIApplicationWillTerminateNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [center addObserverForName:UIApplicationWillTerminateNotification object:nil queue:nil + usingBlock:^(__attribute__((unused)) NSNotification * _Nonnull note) { __strong __typeof__(self) strongSelf = weakSelf; [strongSelf.kvStore setBoolean:YES forKey:SYSTEMSTATE_APP_WAS_TERMINATED]; // No need to update since we are shutting down. }]; - [center addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [center addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:nil + usingBlock:^(__attribute__((unused)) NSNotification * _Nonnull note) { __strong __typeof__(self) strongSelf = weakSelf; [strongSelf.kvStore setBoolean:YES forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; [strongSelf setValue:@YES forAppKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; }]; - [center addObserverForName:UIApplicationDidEnterBackgroundNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [center addObserverForName:UIApplicationDidEnterBackgroundNotification object:nil queue:nil + usingBlock:^(__attribute__((unused)) NSNotification * _Nonnull note) { __strong __typeof__(self) strongSelf = weakSelf; [strongSelf.kvStore setBoolean:NO forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; [strongSelf setValue:@NO forAppKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; }]; - [center addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [center addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:nil + usingBlock:^(__attribute__((unused)) NSNotification * _Nonnull note) { __strong __typeof__(self) strongSelf = weakSelf; [strongSelf.kvStore setBoolean:YES forKey:SYSTEMSTATE_APP_IS_ACTIVE]; [strongSelf setValue:@YES forAppKey:SYSTEMSTATE_APP_IS_ACTIVE]; }]; - [center addObserverForName:UIApplicationWillResignActiveNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { + [center addObserverForName:UIApplicationWillResignActiveNotification object:nil queue:nil + usingBlock:^(__attribute__((unused)) NSNotification * _Nonnull note) { __strong __typeof__(self) strongSelf = weakSelf; [strongSelf.kvStore setBoolean:NO forKey:SYSTEMSTATE_APP_IS_ACTIVE]; [strongSelf setValue:@NO forAppKey:SYSTEMSTATE_APP_IS_ACTIVE]; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+AppHangs.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+AppHangs.m index 0b8502b2fa..3f36a7ce29 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+AppHangs.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+AppHangs.m @@ -55,7 +55,7 @@ - (void)appHangDetectedWithThreads:(nonnull NSArray *)threads { handledState:handledState user:self.configuration.user metadata:[self.metadata deepCopy] - breadcrumbs:self.breadcrumbs.breadcrumbs + breadcrumbs:self.breadcrumbs.breadcrumbs ?: @[] errors:@[error] threads:threads session:self.sessionTracker.runningSession]; @@ -75,7 +75,7 @@ - (void)appHangEnded { const BOOL fatalOnly = self.configuration.appHangThresholdMillis == BugsnagAppHangThresholdFatalOnly; if (!fatalOnly && self.appHangEvent) { - [self notifyInternal:self.appHangEvent block:nil]; + [self notifyInternal:(BugsnagEvent * _Nonnull)self.appHangEvent block:nil]; } self.appHangEvent = nil; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+OutOfMemory.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+OutOfMemory.m index 944ee0a24f..806a9a6dbb 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+OutOfMemory.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+OutOfMemory.m @@ -33,7 +33,10 @@ - (BugsnagEvent *)generateOutOfMemoryEvent { device.orientation = self.stateMetadataFromLastLaunch[BSGKeyDeviceState][BSGKeyOrientation]; BugsnagMetadata *metadata = [[BugsnagMetadata alloc] initWithDictionary:self.metadataFromLastLaunch ?: @{}]; - [metadata addMetadata:self.stateMetadataFromLastLaunch[BSGKeyDeviceState] toSection:BSGKeyDevice]; + NSDictionary *deviceState = self.stateMetadataFromLastLaunch[BSGKeyDeviceState]; + if ([deviceState isKindOfClass:[NSDictionary class]]) { + [metadata addMetadata:deviceState toSection:BSGKeyDevice]; + } NSDictionary *sessionDict = self.systemState.lastLaunchState[BSGKeySession]; BugsnagSession *session = sessionDict ? [[BugsnagSession alloc] initWithDictionary:sessionDict] : nil; @@ -49,11 +52,11 @@ - (BugsnagEvent *)generateOutOfMemoryEvent { [[BugsnagEvent alloc] initWithApp:app device:device handledState:[BugsnagHandledState handledStateWithSeverityReason:LikelyOutOfMemory] - user:session.user + user:session.user ?: [[BugsnagUser alloc] init] metadata:metadata - breadcrumbs:self.breadcrumbs.breadcrumbs + breadcrumbs:self.breadcrumbs.breadcrumbs ?: @[] errors:@[error] - threads:nil + threads:@[] session:session]; return event; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+Private.h index a610e89234..ca5f9b7132 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+Private.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+Private.h @@ -39,11 +39,11 @@ NS_ASSUME_NONNULL_BEGIN @property (nullable, nonatomic) NSString *codeBundleId; -@property (readonly) NSString *configMetadataFile; +@property (readonly, nonatomic) NSString *configMetadataFile; -@property (nullable) NSDictionary *configMetadataFromLastLaunch; +@property (nullable, nonatomic) NSDictionary *configMetadataFromLastLaunch; -@property (nullable, retain, nonatomic) BugsnagConfiguration *configuration; +@property (retain, nonatomic) BugsnagConfiguration *configuration; @property (strong, nonatomic) BugsnagCrashSentry *crashSentry; @@ -52,7 +52,7 @@ NS_ASSUME_NONNULL_BEGIN @property (strong, nonatomic) BSGEventUploader *eventUploader; -@property NSMutableDictionary *extraRuntimeInfo; +@property (nonatomic) NSMutableDictionary *extraRuntimeInfo; #if TARGET_OS_IOS @property (strong, nonatomic) NSString *lastOrientation; @@ -60,9 +60,9 @@ NS_ASSUME_NONNULL_BEGIN @property (strong, nonatomic) BugsnagMetadata *metadata; // Used in BugsnagReactNative -@property (readonly) NSString *metadataFile; +@property (readonly, nonatomic) NSString *metadataFile; -@property (nullable) NSDictionary *metadataFromLastLaunch; +@property (nullable, nonatomic) NSDictionary *metadataFromLastLaunch; @property (strong, nonatomic) BugsnagNotifier *notifier; // Used in BugsnagReactNative @@ -76,9 +76,9 @@ NS_ASSUME_NONNULL_BEGIN @property (strong, nonatomic) NSMutableArray *stateEventBlocks; -@property (readonly) NSString *stateMetadataFile; +@property (readonly, nonatomic) NSString *stateMetadataFile; -@property (nullable) NSDictionary *stateMetadataFromLastLaunch; +@property (nullable, nonatomic) NSDictionary *stateMetadataFromLastLaunch; @property (strong, nonatomic) BugsnagSystemState *systemState; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient.m index 9845271f1d..ed4be81456 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient.m @@ -81,7 +81,7 @@ #if BSG_PLATFORM_IOS #import "BSGUIKit.h" #elif BSG_PLATFORM_OSX -#import +#import "BSGAppKit.h" #endif NSString *const BSTabCrash = @"crash"; @@ -123,7 +123,7 @@ - (NSDictionary *)BSG_mergedInto:(NSDictionary *)dest; * * @param writer report writer which will receive updated metadata */ -void BSSerializeDataCrashHandler(const BSG_KSCrashReportWriter *writer, int type) { +void BSSerializeDataCrashHandler(const BSG_KSCrashReportWriter *writer, __attribute__((unused)) int type) { BOOL isCrash = YES; if (hasRecordedSessions) { // a session is available // persist session info @@ -223,9 +223,9 @@ void BSGWriteSessionCrashData(BugsnagSession *session) { @interface BugsnagClient () -@property BSGNotificationBreadcrumbs *notificationBreadcrumbs; +@property (nonatomic) BSGNotificationBreadcrumbs *notificationBreadcrumbs; -@property (weak) NSTimer *appLaunchTimer; +@property (weak, nonatomic) NSTimer *appLaunchTimer; @end @@ -249,7 +249,7 @@ - (instancetype)initWithConfiguration:(BugsnagConfiguration *)configuration { _configuration = [configuration copy]; _state = [[BugsnagMetadata alloc] initWithDictionary:@{BSGKeyApp: @{BSGKeyIsLaunching: @YES}}]; self.notifier = [BugsnagNotifier new]; - self.systemState = [[BugsnagSystemState alloc] initWithConfiguration:self.configuration]; + self.systemState = [[BugsnagSystemState alloc] initWithConfiguration:configuration]; BSGFileLocations *fileLocations = [BSGFileLocations current]; @@ -352,7 +352,7 @@ - (void)notifyObservers:(BugsnagStateEvent *)event { - (void)start { [self.configuration validate]; - [self.crashSentry install:self.configuration notifier:self.notifier onCrash:&BSSerializeDataCrashHandler]; + [self.crashSentry install:self.configuration onCrash:&BSSerializeDataCrashHandler]; [self.systemState recordAppUUID]; // Needs to be called after crashSentry installed but before -computeDidCrashLastLaunch [self computeDidCrashLastLaunch]; [self.breadcrumbs removeAllBreadcrumbs]; @@ -418,7 +418,7 @@ - (void)start { [self.pluginClient loadPlugins]; if (self.configuration.launchDurationMillis > 0) { - self.appLaunchTimer = [NSTimer scheduledTimerWithTimeInterval:self.configuration.launchDurationMillis / 1000.0 + self.appLaunchTimer = [NSTimer scheduledTimerWithTimeInterval:(double)self.configuration.launchDurationMillis / 1000.0 target:self selector:@selector(appLaunchTimerFired:) userInfo:nil repeats:NO]; } @@ -428,7 +428,7 @@ - (void)start { } if (self.eventFromLastLaunch) { - [self.eventUploader uploadEvent:self.eventFromLastLaunch completionHandler:nil]; + [self.eventUploader uploadEvent:(BugsnagEvent * _Nonnull)self.eventFromLastLaunch completionHandler:nil]; self.eventFromLastLaunch = nil; } @@ -444,7 +444,7 @@ - (void)start { self.stateMetadataFromLastLaunch = nil; } -- (void)appLaunchTimerFired:(NSTimer *)timer { +- (void)appLaunchTimerFired:(__attribute__((unused)) NSTimer *)timer { [self markLaunchCompleted]; } @@ -467,7 +467,7 @@ - (void)sendLaunchCrashSynchronously { dispatch_semaphore_signal(semaphore); }; if (self.eventFromLastLaunch) { - [self.eventUploader uploadEvent:self.eventFromLastLaunch completionHandler:completionHandler]; + [self.eventUploader uploadEvent:(BugsnagEvent * _Nonnull)self.eventFromLastLaunch completionHandler:completionHandler]; self.eventFromLastLaunch = nil; } else { [self.eventUploader uploadLatestStoredEvent:completionHandler]; @@ -519,10 +519,12 @@ - (BOOL)didLikelyOOM { } // If the app code changed between launches, assume no OOM. - if (![prevAppState[SYSTEMSTATE_APP_VERSION] isEqualToString:currAppState[SYSTEMSTATE_APP_VERSION]]) { + NSString *currentAppVersion = currAppState[SYSTEMSTATE_APP_VERSION]; + if (!currentAppVersion || ![prevAppState[SYSTEMSTATE_APP_VERSION] isEqualToString:currentAppVersion]) { return NO; } - if (![prevAppState[SYSTEMSTATE_APP_BUNDLE_VERSION] isEqualToString:currAppState[SYSTEMSTATE_APP_BUNDLE_VERSION]]) { + NSString *currentAppBundleVersion = currAppState[SYSTEMSTATE_APP_BUNDLE_VERSION]; + if (!currentAppBundleVersion || ![prevAppState[SYSTEMSTATE_APP_BUNDLE_VERSION] isEqualToString:currentAppBundleVersion]) { return NO; } @@ -613,7 +615,7 @@ - (void)setStarted:(BOOL)started { /** * Removes observers and listeners to prevent allocations when the app is terminated */ -- (void)unsubscribeFromNotifications:(id)sender { +- (void)unsubscribeFromNotifications:(__attribute__((unused)) id)sender { [[NSNotificationCenter defaultCenter] removeObserver:self]; [BSGConnectivity stopMonitoring]; @@ -646,11 +648,11 @@ - (void)watchLifecycleEvents:(NSNotificationCenter *)center { object:nil]; } -- (void)willEnterForeground:(id)sender { +- (void)willEnterForeground:(__attribute__((unused)) id)sender { [self.sessionTracker handleAppForegroundEvent]; } -- (void)willEnterBackground:(id)sender { +- (void)willEnterBackground:(__attribute__((unused)) id)sender { [self.sessionTracker handleAppBackgroundEvent]; } @@ -711,7 +713,7 @@ - (void)leaveBreadcrumbWithMessage:(NSString *_Nonnull)message andType:(BSGBreadcrumbType)type { [self addBreadcrumbWithBlock:^(BugsnagBreadcrumb *_Nonnull crumbs) { crumbs.message = message; - crumbs.metadata = metadata; + crumbs.metadata = metadata ?: @{}; crumbs.type = type; }]; } @@ -763,7 +765,7 @@ - (void)removeOnBreadcrumbBlock:(BugsnagOnBreadcrumbBlock _Nonnull)block { // MARK: - Other methods // ============================================================================= -- (void)setContext:(NSString *_Nullable)context { +- (void)setContext:(nullable NSString *)context { self.configuration.context = context; [self notifyObservers:[[BugsnagStateEvent alloc] initWithName:kStateEventContext data:context]]; } @@ -864,7 +866,7 @@ - (void)notify:(NSException *)exception * 2. -[BugsnagClient notifyError:block:] * 3. -[BugsnagClient notify:handledState:block:] */ - int depth = 3; + NSUInteger depth = 3; NSArray *callStack = exception.callStackReturnAddresses; if (!callStack.count) { @@ -894,7 +896,7 @@ - (void)notify:(NSException *)exception handledState:handledState user:self.user metadata:metadata - breadcrumbs:self.breadcrumbs.breadcrumbs + breadcrumbs:self.breadcrumbs.breadcrumbs ?: @[] errors:@[error] threads:threads session:self.sessionTracker.runningSession]; @@ -977,7 +979,7 @@ - (void)addAutoBreadcrumbForEvent:(BugsnagEvent *)event { } [self addAutoBreadcrumbOfType:BSGBreadcrumbTypeError - withMessage:event.errors[0].errorClass + withMessage:event.errors[0].errorClass ?: @"" andMetadata:metadata]; } @@ -1001,7 +1003,7 @@ - (void)metadataChanged:(BugsnagMetadata *)metadata { * @param notification The change notification */ #if BSG_PLATFORM_IOS -- (void)batteryChanged:(NSNotification *)notification { +- (void)batteryChanged:(__attribute__((unused)) NSNotification *)notification { if (![UIDEVICE currentDevice]) { return; } @@ -1059,7 +1061,7 @@ - (void)orientationChanged:(NSNotification *)notification { self.lastOrientation = orientation; } -- (void)lowMemoryWarning:(NSNotification *)notif { +- (void)lowMemoryWarning:(__attribute__((unused)) NSNotification *)notif { [self.state addMetadata:[BSG_RFC3339DateTool stringFromDate:[NSDate date]] withKey:BSEventLowMemoryWarning toSection:BSGKeyDeviceState]; @@ -1179,7 +1181,7 @@ - (NSArray *)collectThreads:(BOOL)unhandled { // discard the following // 1. [BugsnagReactNative getPayloadInfo:resolve:reject:] // 2. [BugsnagClient collectThreads:] - int depth = 2; + NSUInteger depth = 2; NSArray *callStack = BSGArraySubarrayFromIndex(NSThread.callStackReturnAddresses, depth); BSGThreadSendPolicy sendThreads = self.configuration.sendThreads; BOOL recordAllThreads = sendThreads == BSGThreadSendPolicyAlways diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BSGConfigurationBuilder.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BSGConfigurationBuilder.m index 52312be739..846b544ffa 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BSGConfigurationBuilder.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BSGConfigurationBuilder.m @@ -98,11 +98,13 @@ + (void)loadEndpoints:(BugsnagConfiguration *)config options:(NSDictionary *)opt if (options[BSGKeyEndpoints] && [options[BSGKeyEndpoints] isKindOfClass:[NSDictionary class]]) { NSDictionary *endpoints = options[BSGKeyEndpoints]; - if ([endpoints[BSGKeyNotifyEndpoint] isKindOfClass:[NSString class]]) { - config.endpoints.notify = endpoints[BSGKeyNotifyEndpoint]; + NSString *notify = endpoints[BSGKeyNotifyEndpoint]; + if ([notify isKindOfClass:[NSString class]]) { + config.endpoints.notify = notify; } - if ([endpoints[BSGKeySessionsEndpoint] isKindOfClass:[NSString class]]) { - config.endpoints.sessions = endpoints[BSGKeySessionsEndpoint]; + NSString *sessions = endpoints[BSGKeySessionsEndpoint]; + if ([sessions isKindOfClass:[NSString class]]) { + config.endpoints.sessions = sessions; } } } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration.m index 58c421fb60..ab9601d851 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration.m @@ -77,7 +77,7 @@ + (instancetype)loadConfigFromOptions:(NSDictionary *)options { * * @param zone This parameter is ignored. Memory zones are no longer used by Objective-C. */ -- (nonnull id)copyWithZone:(nullable NSZone *)zone { +- (nonnull id)copyWithZone:(nullable __attribute__((unused)) NSZone *)zone { BugsnagConfiguration *copy = [[BugsnagConfiguration alloc] initWithApiKey:[self.apiKey copy]]; // Omit apiKey - it's set explicitly in the line above [copy setAppHangThresholdMillis:self.appHangThresholdMillis]; @@ -265,7 +265,7 @@ - (instancetype)initWithDictionaryRepresentation:(NSDictionary * */ - (BOOL)shouldSendReports { return self.enabledReleaseStages.count == 0 || - [self.enabledReleaseStages containsObject:self.releaseStage]; + [self.enabledReleaseStages containsObject:self.releaseStage ?: @""]; } - (void)setUser:(NSString *_Nullable)userId @@ -540,19 +540,19 @@ - (BOOL)shouldRecordBreadcrumbType:(BSGBreadcrumbType)type { case BSGBreadcrumbTypeManual: return YES; case BSGBreadcrumbTypeError : - return self.enabledBreadcrumbTypes & BSGEnabledBreadcrumbTypeError; + return (self.enabledBreadcrumbTypes & BSGEnabledBreadcrumbTypeError) != 0; case BSGBreadcrumbTypeLog: - return self.enabledBreadcrumbTypes & BSGEnabledBreadcrumbTypeLog; + return (self.enabledBreadcrumbTypes & BSGEnabledBreadcrumbTypeLog) != 0; case BSGBreadcrumbTypeNavigation: - return self.enabledBreadcrumbTypes & BSGEnabledBreadcrumbTypeNavigation; + return (self.enabledBreadcrumbTypes & BSGEnabledBreadcrumbTypeNavigation) != 0; case BSGBreadcrumbTypeProcess: - return self.enabledBreadcrumbTypes & BSGEnabledBreadcrumbTypeProcess; + return (self.enabledBreadcrumbTypes & BSGEnabledBreadcrumbTypeProcess) != 0; case BSGBreadcrumbTypeRequest: - return self.enabledBreadcrumbTypes & BSGEnabledBreadcrumbTypeRequest; + return (self.enabledBreadcrumbTypes & BSGEnabledBreadcrumbTypeRequest) != 0; case BSGBreadcrumbTypeState: - return self.enabledBreadcrumbTypes & BSGEnabledBreadcrumbTypeState; + return (self.enabledBreadcrumbTypes & BSGEnabledBreadcrumbTypeState) != 0; case BSGBreadcrumbTypeUser: - return self.enabledBreadcrumbTypes & BSGEnabledBreadcrumbTypeUser; + return (self.enabledBreadcrumbTypes & BSGEnabledBreadcrumbTypeUser) != 0; } return NO; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGConnectivity.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGConnectivity.m index 460a89a512..cf8a08e3e8 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGConnectivity.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGConnectivity.m @@ -74,7 +74,7 @@ BOOL BSGConnectivityShouldReportChange(SCNetworkReachabilityFlags flags) { * Textual representation of a connection type */ NSString *BSGConnectivityFlagRepresentation(SCNetworkReachabilityFlags flags) { - BOOL connected = (flags & kSCNetworkReachabilityFlagsReachable); + BOOL connected = (flags & kSCNetworkReachabilityFlagsReachable) != 0; #if BSG_PLATFORM_IOS || BSG_PLATFORM_TVOS return connected ? ((flags & kSCNetworkReachabilityFlagsIsWWAN) ? BSGConnectivityCellular : BSGConnectivityWiFi) @@ -88,12 +88,12 @@ BOOL BSGConnectivityShouldReportChange(SCNetworkReachabilityFlags flags) { * Callback invoked by SCNetworkReachability, which calls an Objective-C block * that handles the connection change. */ -void BSGConnectivityCallback(SCNetworkReachabilityRef target, +void BSGConnectivityCallback(__attribute__((unused)) SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, - void *info) + __attribute__((unused)) void *info) { if (bsg_reachability_change_block && BSGConnectivityShouldReportChange(flags)) { - BOOL connected = (flags & kSCNetworkReachabilityFlagsReachable); + BOOL connected = (flags & kSCNetworkReachabilityFlagsReachable) != 0; bsg_reachability_change_block(connected, BSGConnectivityFlagRepresentation(flags)); } } @@ -109,12 +109,12 @@ + (void)monitorURL:(NSURL *)URL usingCallback:(BSGConnectivityChangeBlock)block bsg_reachability_change_block = block; - NSString *host = [URL host]; - if (![self isValidHostname:host]) { + const char *nodename = URL.host.UTF8String; + if (!nodename || ![self isValidHostname:@(nodename)]) { return; } - bsg_reachability_ref = SCNetworkReachabilityCreateWithName(NULL, [host UTF8String]); + bsg_reachability_ref = SCNetworkReachabilityCreateWithName(NULL, nodename); if (bsg_reachability_ref) { // Can be null if a bad hostname was specified SCNetworkReachabilitySetCallback(bsg_reachability_ref, BSGConnectivityCallback, NULL); SCNetworkReachabilitySetDispatchQueue(bsg_reachability_ref, reachabilityQueue); diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGEventUploadFileOperation.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGEventUploadFileOperation.m index 39cd67f88c..8a9a6fb3d9 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGEventUploadFileOperation.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGEventUploadFileOperation.m @@ -23,7 +23,7 @@ - (instancetype)initWithFile:(NSString *)file delegate:(id)delegate completion requestHeaders[BugsnagHTTPHeaderNameSentAt] = [BSG_RFC3339DateTool stringFromDate:[NSDate date]]; requestHeaders[BugsnagHTTPHeaderNameStacktraceTypes] = [event.stacktraceTypes componentsJoinedByString:@","]; - [delegate.apiClient sendJSONPayload:requestPayload headers:requestHeaders toURL:configuration.notifyURL - completionHandler:^(BugsnagApiClientDeliveryStatus status, NSError *error) { + NSURL *notifyURL = configuration.notifyURL; + if (!notifyURL) { + bsg_log_err(@"Could not upload event %@ because notifyURL was nil", self.name); + completionHandler(); + return; + } + + [delegate.apiClient sendJSONPayload:requestPayload headers:requestHeaders toURL:notifyURL + completionHandler:^(BugsnagApiClientDeliveryStatus status, __attribute__((unused)) NSError *deliveryError) { switch (status) { case BugsnagApiClientDeliveryStatusDelivered: @@ -139,7 +146,7 @@ - (void)runWithDelegate:(id)delegate completion // MARK: Subclassing -- (BugsnagEvent *)loadEventAndReturnError:(NSError **)errorPtr { +- (BugsnagEvent *)loadEventAndReturnError:(__attribute__((unused)) NSError * __autoreleasing *)errorPtr { // Must be implemented by all subclasses [self doesNotRecognizeSelector:_cmd]; return nil; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGEventUploader.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGEventUploader.m index 1a770893a4..ec91612421 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGEventUploader.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BSGEventUploader.m @@ -140,7 +140,11 @@ - (void)uploadLatestStoredEvent:(void (^)(void))completionHandler { } [files sortUsingComparator:^NSComparisonResult(NSString *lhs, NSString *rhs) { - return [creationDates[lhs] compare:creationDates[rhs]]; + NSDate *rhsDate = creationDates[rhs]; + if (!rhsDate) { + return NSOrderedDescending; + } + return [creationDates[lhs] compare:rhsDate]; }]; return files; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.h index 9023ad53bb..b487b48a19 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.h @@ -42,7 +42,7 @@ typedef NS_ENUM(NSInteger, BugsnagApiClientDeliveryStatus) { - (NSString *)SHA1HashStringWithData:(NSData *)data; -@property(readonly) NSOperationQueue *sendQueue; +@property (readonly, nonatomic) NSOperationQueue *sendQueue; @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.m index f6176537f9..e3ede19bbe 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.m @@ -95,10 +95,11 @@ - (void)sendJSONPayload:(NSDictionary *)payload NSMutableURLRequest *request = [self prepareRequest:url headers:mutableHeaders]; bsg_log_debug(@"Sending %lu byte payload to %@", (unsigned long)data.length, url); - [[self.session uploadTaskWithRequest:request fromData:data completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + [[self.session uploadTaskWithRequest:request fromData:data completionHandler:^(__attribute__((unused)) NSData *responseData, + NSURLResponse *response, NSError *connectionError) { if (![response isKindOfClass:[NSHTTPURLResponse class]]) { bsg_log_debug(@"Request to %@ completed with error %@", url, error); - completionHandler(BugsnagApiClientDeliveryStatusFailed, error ?: + completionHandler(BugsnagApiClientDeliveryStatusFailed, connectionError ?: [NSError errorWithDomain:@"BugsnagApiClientErrorDomain" code:0 userInfo:@{ NSLocalizedDescriptionKey: @"Request failed: no response was received", NSURLErrorFailingURLErrorKey: url }]); @@ -113,7 +114,7 @@ - (void)sendJSONPayload:(NSDictionary *)payload return; } - error = [NSError errorWithDomain:@"BugsnagApiClientErrorDomain" code:1 userInfo:@{ + connectionError = [NSError errorWithDomain:@"BugsnagApiClientErrorDomain" code:1 userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Request failed: unacceptable status code %ld (%@)", (long)statusCode, [NSHTTPURLResponse localizedStringForStatusCode:statusCode]], NSURLErrorFailingURLErrorKey: url }]; @@ -126,11 +127,11 @@ - (void)sendJSONPayload:(NSDictionary *)payload statusCode != HTTPStatusCodeProxyAuthenticationRequired && statusCode != HTTPStatusCodeClientTimeout && statusCode != HTTPStatusCodeTooManyRequests) { - completionHandler(BugsnagApiClientDeliveryStatusUndeliverable, error); + completionHandler(BugsnagApiClientDeliveryStatusUndeliverable, connectionError); return; } - completionHandler(BugsnagApiClientDeliveryStatusFailed, error); + completionHandler(BugsnagApiClientDeliveryStatusFailed, connectionError); }] resume]; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.h index abe1b71ba7..2cb08547bb 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.h @@ -21,8 +21,8 @@ */ - (void)deliverSessionsInStore:(BugsnagSessionFileStore *)store; -@property (copy) NSString *codeBundleId; +@property (copy, nonatomic) NSString *codeBundleId; -@property BugsnagNotifier *notifier; +@property (nonatomic) BugsnagNotifier *notifier; @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.m index 67f783b60c..684e0f180b 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.m @@ -14,7 +14,7 @@ #import "BSG_RFC3339DateTool.h" @interface BugsnagSessionTrackingApiClient () -@property NSMutableSet *activeIds; +@property (nonatomic) NSMutableSet *activeIds; @property(nonatomic) BugsnagConfiguration *config; @end @@ -43,20 +43,17 @@ - (void)deliverSessionsInStore:(BugsnagSessionFileStore *)store { return; } - NSDictionary *filesWithIds = [store allFilesByName]; - - for (NSString *fileId in [filesWithIds allKeys]) { - + [[store allFilesByName] enumerateKeysAndObjectsUsingBlock:^(NSString *fileId, NSDictionary *fileContents, __attribute__((unused)) BOOL *stop) { // De-duplicate files as deletion of the file is asynchronous and so multiple calls // to this method will result in multiple send requests @synchronized (self.activeIds) { if ([self.activeIds containsObject:fileId]) { - continue; + return; } [self.activeIds addObject:fileId]; } - BugsnagSession *session = [[BugsnagSession alloc] initWithDictionary:filesWithIds[fileId]]; + BugsnagSession *session = [[BugsnagSession alloc] initWithDictionary:fileContents]; [self.sendQueue addOperationWithBlock:^{ BugsnagSessionTrackingPayload *payload = [[BugsnagSessionTrackingPayload alloc] @@ -90,7 +87,7 @@ - (void)deliverSessionsInStore:(BugsnagSessionFileStore *)store { } }]; }]; - } + }]; } @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGAppHangDetector.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGAppHangDetector.m index 9ef681f931..c05652bf94 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGAppHangDetector.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGAppHangDetector.m @@ -12,20 +12,50 @@ #import #import "BSG_KSMach.h" +#import "BugsnagCollections.h" #import "BugsnagLogger.h" #import "BugsnagThread+Recording.h" #import "BugsnagThread+Private.h" +#if TARGET_OS_IOS +#import "BSGUIKit.h" +#endif + @interface BSGAppHangDetector () @property (nonatomic) CFRunLoopObserverRef observer; +@property (nonatomic) BOOL isInBackground; + @end @implementation BSGAppHangDetector +#if TARGET_OS_IOS + +- (instancetype)init { + if (self = [super init]) { + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(applicationDidEnterBackground) + name:UIApplicationDidEnterBackgroundNotification object:nil]; + + [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(applicationWillEnterForeground) + name:UIApplicationWillEnterForegroundNotification object:nil]; + } + return self; +} + +- (void)applicationDidEnterBackground { + self.isInBackground = YES; +} + +- (void)applicationWillEnterForeground { + self.isInBackground = NO; +} + +#endif + - (void)dealloc { if (_observer) { CFRunLoopRemoveObserver(CFRunLoopGetMain(), _observer, kCFRunLoopCommonModes); @@ -52,17 +82,19 @@ - (void)startWithDelegate:(id)delegate { const BOOL fatalOnly = configuration.appHangThresholdMillis == BugsnagAppHangThresholdFatalOnly; const BOOL recordAllThreads = configuration.sendThreads == BSGThreadSendPolicyAlways; - const NSTimeInterval threshold = fatalOnly ? 2 : configuration.appHangThresholdMillis / 1000.0; + const NSTimeInterval threshold = fatalOnly ? 2.0 : (double)configuration.appHangThresholdMillis / 1000.0; bsg_log_debug(@"Starting App Hang detector with threshold = %g seconds", threshold); dispatch_queue_t backgroundQueue; __block dispatch_semaphore_t semaphore; __weak typeof(delegate) weakDelegate = delegate; + __weak typeof(self) weakSelf = self; backgroundQueue = dispatch_queue_create("com.bugsnag.app-hang-detector", DISPATCH_QUEUE_SERIAL); - void (^ observerBlock)(CFRunLoopObserverRef, CFRunLoopActivity) = ^(CFRunLoopObserverRef observer, CFRunLoopActivity activity) { + void (^ observerBlock)(CFRunLoopObserverRef, CFRunLoopActivity) = + ^(__attribute__((unused)) CFRunLoopObserverRef observer, CFRunLoopActivity activity) { // "Inside the event processing loop after the run loop wakes up, but before processing the event that woke it up" if (activity == kCFRunLoopAfterWaiting) { if (!semaphore) { @@ -75,6 +107,12 @@ - (void)startWithDelegate:(id)delegate { dispatch_time_t timeout = dispatch_time(now, (int64_t)(threshold * NSEC_PER_SEC)); dispatch_after(after, backgroundQueue, ^{ if (dispatch_semaphore_wait(semaphore, timeout) != 0) { + if (weakSelf.isInBackground) { + bsg_log_debug(@"Ignoring app hang because app is in the background"); + dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); + return; + } + if (bsg_ksmachisBeingTraced()) { bsg_log_debug("Ignoring app hang because debugger is attached"); dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); @@ -87,19 +125,22 @@ - (void)startWithDelegate:(id)delegate { if (recordAllThreads) { threads = [BugsnagThread allThreads:YES callStackReturnAddresses:NSThread.callStackReturnAddresses]; // By default the calling thread is marked as "Error reported from this thread", which is not correct case for app hangs. - [threads enumerateObjectsUsingBlock:^(BugsnagThread * _Nonnull thread, NSUInteger idx, BOOL * _Nonnull stop) { + [threads enumerateObjectsUsingBlock:^(BugsnagThread * _Nonnull thread, NSUInteger idx, + __attribute__((unused)) BOOL * _Nonnull stop) { thread.errorReportingThread = idx == 0; }]; } else { - threads = [NSArray arrayWithObjects:[BugsnagThread mainThread], nil]; //!OCLint + threads = BSGArrayWithObject([BugsnagThread mainThread]); } - [weakDelegate appHangDetectedWithThreads:threads]; + __strong typeof(weakDelegate) strongDelegate = weakDelegate; + + [strongDelegate appHangDetectedWithThreads:threads]; dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER); bsg_log_info("App hang has ended"); - [weakDelegate appHangEnded]; + [strongDelegate appHangEnded]; } }); } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGAppKit.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGAppKit.h new file mode 100644 index 0000000000..44be5da635 --- /dev/null +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGAppKit.h @@ -0,0 +1,41 @@ +// +// BSGAppKit.h +// Bugsnag +// +// Created by Nick Dowell on 13/04/2021. +// Copyright © 2021 Bugsnag Inc. All rights reserved. +// + +#import + +// Daemons and other processes running in non-UI sessions should not link against AppKit. +// These macros exist to allow the use of AppKit without adding a link-time dependency on it. + +// Calling code should be prepared for classes to not be found when AppKit is not linked. +#define NSAPPLICATION NSClassFromString(@"NSApplication") +#define NSMENUITEM NSClassFromString(@"NSMenuItem") +#define NSWORKSPACE NSClassFromString(@"NSWorkspace") + +#define NSApplicationDidBecomeActiveNotification @"NSApplicationDidBecomeActiveNotification" +#define NSApplicationDidBecomeActiveNotification @"NSApplicationDidBecomeActiveNotification" +#define NSApplicationDidFinishLaunchingNotification @"NSApplicationDidFinishLaunchingNotification" +#define NSApplicationDidHideNotification @"NSApplicationDidHideNotification" +#define NSApplicationDidResignActiveNotification @"NSApplicationDidResignActiveNotification" +#define NSApplicationDidResignActiveNotification @"NSApplicationDidResignActiveNotification" +#define NSApplicationDidUnhideNotification @"NSApplicationDidUnhideNotification" +#define NSApplicationWillBecomeActiveNotification @"NSApplicationWillBecomeActiveNotification" +#define NSApplicationWillTerminateNotification @"NSApplicationWillTerminateNotification" +#define NSApplicationWillTerminateNotification @"NSApplicationWillTerminateNotification" +#define NSControlTextDidBeginEditingNotification @"NSControlTextDidBeginEditingNotification" +#define NSControlTextDidEndEditingNotification @"NSControlTextDidEndEditingNotification" +#define NSMenuWillSendActionNotification @"NSMenuWillSendActionNotification" +#define NSTableViewSelectionDidChangeNotification @"NSTableViewSelectionDidChangeNotification" +#define NSUndoManagerDidRedoChangeNotification @"NSUndoManagerDidRedoChangeNotification" +#define NSUndoManagerDidUndoChangeNotification @"NSUndoManagerDidUndoChangeNotification" +#define NSWindowDidBecomeKeyNotification @"NSWindowDidBecomeKeyNotification" +#define NSWindowDidEnterFullScreenNotification @"NSWindowDidEnterFullScreenNotification" +#define NSWindowDidExitFullScreenNotification @"NSWindowDidExitFullScreenNotification" +#define NSWindowWillCloseNotification @"NSWindowWillCloseNotification" +#define NSWindowWillMiniaturizeNotification @"NSWindowWillMiniaturizeNotification" +#define NSWorkspaceScreensDidSleepNotification @"NSWorkspaceScreensDidSleepNotification" +#define NSWorkspaceScreensDidWakeNotification @"NSWorkspaceScreensDidWakeNotification" diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.h index 8aedfe573d..ce1b38988f 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.h @@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN - NSNumbers are not NaN or infinity Other rules may apply. Calling this method or attempting a conversion are the definitive ways to tell if a given object can be converted to JSON data. */ -+ (BOOL)isValidJSONObject:(id)obj; ++ (BOOL)isValidJSONObject:(nullable id)obj; /* Generate JSON data from a Foundation object. If the object will not produce valid JSON then an error will be returned. Setting the NSJSONWritingPrettyPrinted option will generate JSON with whitespace designed to make the output more readable. If that option is not set, the most compact possible JSON will be generated. If an error occurs, the error parameter will be set and the return value will be nil. The resulting data is a encoded in UTF-8. */ diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.m index c344a0764e..3e37cc3080 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.m @@ -17,15 +17,15 @@ @implementation BSGJSONSerialization }]; } -+ (BOOL)isValidJSONObject:(id)obj { ++ (BOOL)isValidJSONObject:(nullable id)obj { @try { - return [NSJSONSerialization isValidJSONObject:obj]; + return obj && [NSJSONSerialization isValidJSONObject:(id _Nonnull)obj]; } @catch (NSException *exception) { return NO; } } -+ (nullable NSData *)dataWithJSONObject:(id)obj options:(NSJSONWritingOptions)opt error:(NSError **)error { ++ (nullable NSData *)dataWithJSONObject:(id)obj options:(NSJSONWritingOptions)opt error:(NSError * __autoreleasing *)error { @try { return [NSJSONSerialization dataWithJSONObject:obj options:opt error:error]; } @catch (NSException *exception) { @@ -36,7 +36,7 @@ + (nullable NSData *)dataWithJSONObject:(id)obj options:(NSJSONWritingOptions)op } } -+ (nullable id)JSONObjectWithData:(NSData *)data options:(NSJSONReadingOptions)opt error:(NSError **)error { ++ (nullable id)JSONObjectWithData:(NSData *)data options:(NSJSONReadingOptions)opt error:(NSError * __autoreleasing *)error { @try { return [NSJSONSerialization JSONObjectWithData:data options:opt error:error]; } @catch (NSException *exception) { @@ -47,7 +47,7 @@ + (nullable id)JSONObjectWithData:(NSData *)data options:(NSJSONReadingOptions)o } } -+ (NSInteger)writeJSONObject:(id)obj toStream:(NSOutputStream *)stream options:(NSJSONWritingOptions)opt error:(NSError **)error { ++ (NSInteger)writeJSONObject:(id)obj toStream:(NSOutputStream *)stream options:(NSJSONWritingOptions)opt error:(NSError * __autoreleasing *)error { @try { return [NSJSONSerialization writeJSONObject:obj toStream:stream options:opt error:error]; } @catch (NSException *exception) { @@ -58,7 +58,7 @@ + (NSInteger)writeJSONObject:(id)obj toStream:(NSOutputStream *)stream options:( } } -+ (nullable id)JSONObjectWithStream:(NSInputStream *)stream options:(NSJSONReadingOptions)opt error:(NSError **)error { ++ (nullable id)JSONObjectWithStream:(NSInputStream *)stream options:(NSJSONReadingOptions)opt error:(NSError * __autoreleasing *)error { @try { return [NSJSONSerialization JSONObjectWithStream:stream options:opt error:error]; } @catch (NSException *exception) { @@ -69,7 +69,7 @@ + (nullable id)JSONObjectWithStream:(NSInputStream *)stream options:(NSJSONReadi } } -+ (BOOL)writeJSONObject:(id)JSONObject toFile:(NSString *)file options:(NSJSONWritingOptions)options error:(NSError **)errorPtr { ++ (BOOL)writeJSONObject:(id)JSONObject toFile:(NSString *)file options:(NSJSONWritingOptions)options error:(NSError * __autoreleasing *)errorPtr { if (![BSGJSONSerialization isValidJSONObject:JSONObject]) { if (errorPtr) { *errorPtr = [NSError errorWithDomain:@"BSGJSONSerializationErrorDomain" code:0 userInfo:@{ @@ -81,7 +81,7 @@ + (BOOL)writeJSONObject:(id)JSONObject toFile:(NSString *)file options:(NSJSONWr return [data writeToFile:file options:NSDataWritingAtomic error:errorPtr]; } -+ (nullable id)JSONObjectWithContentsOfFile:(NSString *)file options:(NSJSONReadingOptions)options error:(NSError **)errorPtr { ++ (nullable id)JSONObjectWithContentsOfFile:(NSString *)file options:(NSJSONReadingOptions)options error:(NSError * __autoreleasing *)errorPtr { NSData *data = [NSData dataWithContentsOfFile:file options:0 error:errorPtr]; if (!data) { return nil; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGSerialization.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGSerialization.m index 1261169e37..eadb82c141 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGSerialization.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGSerialization.m @@ -39,7 +39,7 @@ id BSGSanitizeObject(id obj) { __block NSMutableDictionary *output = [NSMutableDictionary dictionaryWithCapacity:[input count]]; [input enumerateKeysAndObjectsUsingBlock:^(id _Nonnull key, id _Nonnull obj, - BOOL *_Nonnull stop) { + __attribute__((unused)) BOOL *_Nonnull stop) { if ([key isKindOfClass:[NSString class]]) { id cleanedObject = BSGSanitizeObject(obj); if (cleanedObject) diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGUIKit.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGUIKit.h index bbe3eae937..d05f39acbf 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGUIKit.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGUIKit.h @@ -11,6 +11,7 @@ // When used in some memory constrained contexts such as a file provider extension, linking to UIKit is problematic. // These macros exist to allow the use of UIKit without adding a link-time dependency on it. +// Calling code should be prepared for classes to not be found when UIKit is not linked. #define UIAPPLICATION NSClassFromString(@"UIApplication") #define UIDEVICE NSClassFromString(@"UIDevice") diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSG_RFC3339DateTool.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSG_RFC3339DateTool.h index 046a1c0ed5..b38bcb4922 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSG_RFC3339DateTool.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSG_RFC3339DateTool.h @@ -51,7 +51,7 @@ * * @return The RFC3339 date string. */ -+ (NSString *)stringFromUNIXTimestamp:(unsigned long long)timestamp; ++ (NSString *)stringFromUNIXTimestamp:(NSTimeInterval)timestamp; /** * Determines whether a string might contain an RFC3339 formatted date. diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSG_RFC3339DateTool.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSG_RFC3339DateTool.m index eeb8db3264..c4b369de8b 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSG_RFC3339DateTool.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSG_RFC3339DateTool.m @@ -81,7 +81,7 @@ + (NSDate *)dateFromString:(NSString *)string { return [g_timezoneAllowedDateFormatter dateFromString:string]; } -+ (NSString *)stringFromUNIXTimestamp:(unsigned long long)timestamp { ++ (NSString *)stringFromUNIXTimestamp:(NSTimeInterval)timestamp { return [self stringFromDate:[NSDate dateWithTimeIntervalSince1970:timestamp]]; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagCollections.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagCollections.h index 374c4a1153..b60e7e76ad 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagCollections.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagCollections.h @@ -23,13 +23,22 @@ NS_ASSUME_NONNULL_BEGIN +// MARK: NSArray + +/// Returns an array with the object, or an empty array if object is nil. +NSArray * BSGArrayWithObject(id _Nullable object); + +void BSGArrayAddIfNonnull(NSMutableArray *array, id _Nullable object); + /// Returns an array containing the results of mapping the given block over the array's elements -NSArray * BSGArrayMap(NSArray *array, id (^ transform)(id)); +NSArray * BSGArrayMap(NSArray * _Nullable array, id _Nullable (^ transform)(id value)); /// Returns a new array containing the elements starting at position `index`, or /// an empty array if `index` is beyond the array's range range of elements. NSArray * BSGArraySubarrayFromIndex(NSArray *array, NSUInteger index); +// MARK: - NSDictionary + /** * Merge values from source dictionary with destination * @@ -43,4 +52,20 @@ NSDictionary *BSGDictMerge(NSDictionary *source, NSDictionary *destination); /// Any values that are not valid JSON will be replaced by a string description. NSDictionary * BSGJSONDictionary(NSDictionary *dictionary); +// MARK: - NSSet + +void BSGSetAddIfNonnull(NSMutableSet *array, id _Nullable object); + +// MARK: - Deserialization + +NSDictionary * _Nullable BSGDeserializeDict(id _Nullable rawValue); + +id _Nullable BSGDeserializeObject(id _Nullable rawValue, id _Nullable (^ deserializer)(NSDictionary * _Nonnull dict)); + +id _Nullable BSGDeserializeArrayOfObjects(id _Nullable rawValue, id _Nullable (^ deserializer)(NSDictionary * _Nonnull dict)); + +NSString * _Nullable BSGDeserializeString(id _Nullable rawValue); + +NSDate * _Nullable BSGDeserializeDate(id _Nullable rawValue); + NS_ASSUME_NONNULL_END diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagCollections.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagCollections.m index 7e08d0b11e..4fbebcd24a 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagCollections.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagCollections.m @@ -21,9 +21,22 @@ #import "BugsnagCollections.h" +#import "BSG_RFC3339DateTool.h" #import "BSGJSONSerialization.h" -NSArray * BSGArrayMap(NSArray *array, id (^ transform)(id)) { +// MARK: NSArray + +NSArray * BSGArrayWithObject(id _Nullable object) { + return object ? @[(id _Nonnull)object] : @[]; +} + +void BSGArrayAddIfNonnull(NSMutableArray *array, id _Nullable object) { + if (object) { + [array addObject:(id _Nonnull)object]; + } +} + +NSArray * BSGArrayMap(NSArray *array, id _Nullable (^ transform)(id)) { NSMutableArray *mappedArray = [NSMutableArray array]; for (id object in array) { id mapped = transform(object); @@ -41,6 +54,8 @@ return [array subarrayWithRange:NSMakeRange(index, array.count - index)]; } +// MARK: - NSDictionary + NSDictionary *BSGDictMerge(NSDictionary *source, NSDictionary *destination) { if ([destination count] == 0) { return source; @@ -85,3 +100,50 @@ } return json; } + +// MARK: - NSSet + +void BSGSetAddIfNonnull(NSMutableSet *set, id _Nullable object) { + if (object) { + [set addObject:(id _Nonnull)object]; + } +} + +// MARK: - Deserialization + +NSDictionary * _Nullable BSGDeserializeDict(id _Nullable rawValue) { + if (![rawValue isKindOfClass:[NSDictionary class]]) { + return nil; + } + return (NSDictionary *)rawValue; +} + +id _Nullable BSGDeserializeObject(id _Nullable rawValue, id _Nullable (^ deserializer)(NSDictionary * _Nonnull dict)) { + if (![rawValue isKindOfClass:[NSDictionary class]]) { + return nil; + } + return deserializer((NSDictionary *)rawValue); +} + +id _Nullable BSGDeserializeArrayOfObjects(id _Nullable rawValue, id _Nullable (^ deserializer)(NSDictionary * _Nonnull dict)) { + if (![rawValue isKindOfClass:[NSArray class]]) { + return nil; + } + return BSGArrayMap((NSArray *)rawValue, ^id _Nullable(id _Nonnull value) { + return BSGDeserializeObject(value, deserializer); + }); +} + +NSString * _Nullable BSGDeserializeString(id _Nullable rawValue) { + if (![rawValue isKindOfClass:[NSString class]]) { + return nil; + } + return (NSString *)rawValue; +} + +NSDate * _Nullable BSGDeserializeDate(id _Nullable rawValue) { + if (![rawValue isKindOfClass:[NSString class]]) { + return nil; + } + return [BSG_RFC3339DateTool dateFromString:(NSString *)rawValue]; +} diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStore.c b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStore.c index e4352854d2..0ee8fc5f28 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStore.c +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKVStore.c @@ -138,7 +138,7 @@ void bsgkv_setBytes(const char* key, const uint8_t* value, int length, int* err) } retry_after_eintr: - if(write(fd, value, length) == length) { + if (write(fd, value, (size_t)length) == length) { goto cleanup_success; } @@ -173,7 +173,8 @@ void bsgkv_getBytes(const char* key, uint8_t* value, int* length, int* err) { *err = errno; return; } - ssize_t bytesRead = read(fd, value, *length); + size_t bytesRequested = (size_t)*length; + ssize_t bytesRead = read(fd, value, bytesRequested); if(bytesRead < 0) { *err = errno; return; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m index 810b336212..348ff54a8e 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m @@ -47,7 +47,7 @@ #import "BSGUIKit.h" #endif #if TARGET_OS_OSX -#import +#import "BSGAppKit.h" #endif // ============================================================================ diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.c b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.c index a8f9d59e2f..047305b9f0 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.c +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashC.c @@ -72,7 +72,7 @@ BSG_KSCrash_Context *crashContext(void) { void bsg_kscrash_i_onCrash(BSG_KSCrash_Context *context) { BSG_KSLOG_DEBUG("Updating application state to note crash."); - bsg_kscrashstate_notifyAppCrash(context->crash.crashType); + bsg_kscrashstate_notifyAppCrash(); if (context->config.printTraceToStdout) { bsg_kscrashreport_logCrash(context); diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReport.c b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReport.c index e00756b2a4..ed6ab2d213 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReport.c +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashReport.c @@ -735,19 +735,21 @@ void bsg_kscrw_i_writeBacktraceEntry( const uintptr_t address, const Dl_info *const info) { writer->beginObject(writer, key); { - if (info->dli_fname != NULL) { - writer->addStringElement(writer, BSG_KSCrashField_ObjectName, - bsg_ksfulastPathEntry(info->dli_fname)); - } - writer->addUIntegerElement(writer, BSG_KSCrashField_ObjectAddr, - (uintptr_t)info->dli_fbase); - if (info->dli_sname != NULL) { - const char *sname = info->dli_sname; - writer->addStringElement(writer, BSG_KSCrashField_SymbolName, - sname); + if (info->dli_saddr != NULL) { + if (info->dli_fname != NULL) { + writer->addStringElement(writer, BSG_KSCrashField_ObjectName, + bsg_ksfulastPathEntry(info->dli_fname)); + } + writer->addUIntegerElement(writer, BSG_KSCrashField_ObjectAddr, + (uintptr_t)info->dli_fbase); + if (info->dli_sname != NULL) { + const char *sname = info->dli_sname; + writer->addStringElement(writer, BSG_KSCrashField_SymbolName, + sname); + } + writer->addUIntegerElement(writer, BSG_KSCrashField_SymbolAddr, + (uintptr_t)info->dli_saddr); } - writer->addUIntegerElement(writer, BSG_KSCrashField_SymbolAddr, - (uintptr_t)info->dli_saddr); writer->addUIntegerElement(writer, BSG_KSCrashField_InstructionAddr, address); } @@ -1240,8 +1242,8 @@ void bsg_kscrw_i_writeError(const BSG_KSCrashReportWriter *const writer, } const char *machExceptionName = bsg_ksmachexceptionName(machExceptionType); - const char *machCodeName = - machCode == 0 ? NULL : bsg_ksmachkernelReturnCodeName(machCode); + const char *machCodeName = machCode == 0 ? NULL : + bsg_ksmachkernelReturnCodeName((kern_return_t)machCode); const char *sigName = bsg_kssignal_signalName(sigNum); const char *sigCodeName = bsg_kssignal_signalCodeName(sigNum, sigCode); @@ -1485,7 +1487,7 @@ void bsg_kscrw_i_updateStackOverflowStatus( void bsg_kscrw_i_callUserCrashHandler(BSG_KSCrash_Context *const crashContext, BSG_KSCrashReportWriter *writer) { BSG_KSCrashType type = crashContext->crash.crashType; - crashContext->config.onCrashNotify(writer, type); + crashContext->config.onCrashNotify(writer, (int)type); } // ============================================================================ diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.h index 4df100ec12..54676e3b3c 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.h @@ -107,7 +107,7 @@ void bsg_kscrashstate_notifyAppTerminate(void); /** Notify the crash reporter that the application has crashed. */ -void bsg_kscrashstate_notifyAppCrash(BSG_KSCrashType type); +void bsg_kscrashstate_notifyAppCrash(void); /** Read-only access into the current state. */ diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.m index 8d09ecbdda..2709c1d9c5 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.m @@ -119,7 +119,7 @@ int bsg_kscrashstate_i_onIntegerElement(const char *const name, } // FP value might have been written as a whole number. - return bsg_kscrashstate_i_onFloatingPointElement(name, value, userData); + return bsg_kscrashstate_i_onFloatingPointElement(name, (double)value, userData); } int bsg_kscrashstate_i_onNullElement(__unused const char *const name, @@ -177,15 +177,20 @@ bool bsg_kscrashstate_i_loadState(BSG_KSCrash_State *const context, if (path == NULL) { return false; } + NSString *file = [NSFileManager.defaultManager stringWithFileSystemRepresentation:path length:strlen(path)]; + if (!file) { + BSG_KSLOG_ERROR(@"Invalid path: %s", path); + return false; + } NSError *error = nil; - NSData *data = [NSData dataWithContentsOfFile:[NSString stringWithUTF8String:path] options:0 error:&error]; + NSData *data = [NSData dataWithContentsOfFile:file options:0 error:&error]; if (error != nil) { if (!(error.domain == NSCocoaErrorDomain && error.code == NSFileReadNoSuchFileError)) { BSG_KSLOG_ERROR(@"%s: Could not load file: %@", path, error); } return false; } - id objectContext = [BSG_KSJSONCodec decode:data options:0 error:&error]; + id objectContext = [BSG_KSJSONCodec decode:data error:&error]; if (error != nil) { BSG_KSLOG_ERROR(@"%s: Could not load file: %@", path, error); return false; @@ -346,7 +351,7 @@ void bsg_kscrashstate_notifyAppTerminate(void) { bsg_kscrashstate_i_saveState(state, stateFilePath); } -void bsg_kscrashstate_notifyAppCrash(BSG_KSCrashType type) { +void bsg_kscrashstate_notifyAppCrash(void) { BSG_KSCrash_State *const state = bsg_g_state; const char *const stateFilePath = bsg_g_stateFilePath; bsg_kscrashstate_updateDurationStats(state); diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.h index 0026dcb546..2a5e9c3a00 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.h @@ -26,6 +26,7 @@ #define BSG_KSSystemField_AppStartTime "app_start_time" #define BSG_KSSystemField_AppUUID "app_uuid" +#define BSG_KSSystemField_BinaryArch "binary_arch" #define BSG_KSSystemField_BootTime "boot_time" #define BSG_KSSystemField_BundleID "CFBundleIdentifier" #define BSG_KSSystemField_BundleName "CFBundleName" @@ -35,8 +36,6 @@ #define BSG_KSSystemField_CPUArch "cpu_arch" #define BSG_KSSystemField_CPUType "cpu_type" #define BSG_KSSystemField_CPUSubType "cpu_subtype" -#define BSG_KSSystemField_BinaryCPUType "binary_cpu_type" -#define BSG_KSSystemField_BinaryCPUSubType "binary_cpu_subtype" #define BSG_KSSystemField_DeviceAppHash "device_app_hash" #define BSG_KSSystemField_Executable "CFBundleExecutable" #define BSG_KSSystemField_ExecutablePath "CFBundleExecutablePath" @@ -54,6 +53,7 @@ #define BSG_KSSystemField_SystemVersion "system_version" #define BSG_KSSystemField_ClangVersion "clang_version" #define BSG_KSSystemField_TimeZone "time_zone" +#define BSG_KSSystemField_Translated "proc_translated" #define BSG_KSSystemField_BuildType "build_type" #define BSG_KSSystemField_iOSSupportVersion "iOSSupportVersion" diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m index 8e02348b1e..65c1ad1562 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m @@ -91,7 +91,7 @@ static inline bool is_jailbroken() { } NSData *data = [NSData dataWithBytesNoCopy:buffer - length:length freeWhenDone:NO]; + length:(NSUInteger)length freeWhenDone:NO]; if (!data) { BSG_KSLOG_ERROR("Could not read SystemVersion.plist"); return; @@ -299,9 +299,19 @@ + (NSString *)CPUArchForCPUType:(cpu_type_t)cpuType case CPU_SUBTYPE_ARM_V7S: return @"armv7s"; #endif + case CPU_SUBTYPE_ARM_V8: + return @"armv8"; } break; } + case CPU_TYPE_ARM64: { + switch (subType) { + case CPU_SUBTYPE_ARM64E: + return @"arm64e"; + default: + return @"arm64"; + } + } case CPU_TYPE_X86: return @"x86"; case CPU_TYPE_X86_64: @@ -436,9 +446,9 @@ + (NSDictionary *)systemInfo { #endif // TARGET_OS_IOS NSDictionary *env = NSProcessInfo.processInfo.environment; - sysInfo[@(BSG_KSSystemField_SystemVersion)] = env[@"SIMULATOR_RUNTIME_VERSION"]; - sysInfo[@(BSG_KSSystemField_Machine)] = env[@"SIMULATOR_MODEL_IDENTIFIER"]; - sysInfo[@(BSG_KSSystemField_Model)] = @"simulator"; + sysInfo[@BSG_KSSystemField_SystemVersion] = env[@"SIMULATOR_RUNTIME_VERSION"]; + sysInfo[@BSG_KSSystemField_Machine] = env[@"SIMULATOR_MODEL_IDENTIFIER"]; + sysInfo[@BSG_KSSystemField_Model] = @"simulator"; #else // !TARGET_OS_SIMULATOR @@ -463,11 +473,11 @@ + (NSDictionary *)systemInfo { NSString *systemName = @"tvOS"; #endif - sysInfo[@(BSG_KSSystemField_SystemName)] = systemName; - sysInfo[@(BSG_KSSystemField_SystemVersion)] = sysVersion[@"ProductVersion"]; + sysInfo[@BSG_KSSystemField_SystemName] = systemName; + sysInfo[@BSG_KSSystemField_SystemVersion] = sysVersion[@"ProductVersion"]; #if TARGET_OS_IOS - sysInfo[@(BSG_KSSystemField_iOSSupportVersion)] = sysVersion[@"iOSSupportVersion"]; + sysInfo[@BSG_KSSystemField_iOSSupportVersion] = sysVersion[@"iOSSupportVersion"]; #endif // Bugsnag payload mapping: @@ -477,15 +487,15 @@ + (NSDictionary *)systemInfo { if ([systemName isEqual:@"Mac OS"]) { // On macOS hw.model contains the "Model Identifier" e.g. MacBookPro16,1 - sysInfo[@(BSG_KSSystemField_Machine)] = [self stringSysctl:@"hw.model"]; + sysInfo[@BSG_KSSystemField_Machine] = [self stringSysctl:@"hw.model"]; // and hw.machine contains the instruction set - e.g. "arm64" or "x86_64" // we omit this since it doesn't match what we're expecting or want. } else { // On iOS & tvOS hw.machine contains the "Model Identifier" or // "ProductType" - e.g. "iPhone6,1" - sysInfo[@(BSG_KSSystemField_Machine)] = [self stringSysctl:@"hw.machine"]; + sysInfo[@BSG_KSSystemField_Machine] = [self stringSysctl:@"hw.machine"]; // and hw.model contains the "Internal Name" or "Board ID" - e.g. "D79AP" - sysInfo[@(BSG_KSSystemField_Model)] = [self stringSysctl:@"hw.model"]; + sysInfo[@BSG_KSSystemField_Model] = [self stringSysctl:@"hw.model"]; } #endif // TARGET_OS_SIMULATOR @@ -506,8 +516,7 @@ + (NSDictionary *)systemInfo { sysInfo[@BSG_KSSystemField_CPUArch] = [self currentCPUArch]; sysInfo[@BSG_KSSystemField_CPUType] = [self int32Sysctl:@BSGKeyHwCputype]; sysInfo[@BSG_KSSystemField_CPUSubType] = [self int32Sysctl:@BSGKeyHwCpusubtype]; - sysInfo[@BSG_KSSystemField_BinaryCPUType] = @(header->cputype); - sysInfo[@BSG_KSSystemField_BinaryCPUSubType] = @(header->cpusubtype); + sysInfo[@BSG_KSSystemField_BinaryArch] = [self CPUArchForCPUType:header->cputype subType:header->cpusubtype]; sysInfo[@BSG_KSSystemField_TimeZone] = [[NSTimeZone localTimeZone] abbreviation]; sysInfo[@BSG_KSSystemField_ProcessName] = [NSProcessInfo processInfo].processName; sysInfo[@BSG_KSSystemField_ProcessID] = @([NSProcessInfo processInfo].processIdentifier); @@ -515,12 +524,21 @@ + (NSDictionary *)systemInfo { sysInfo[@BSG_KSSystemField_DeviceAppHash] = [self deviceAndAppHash]; sysInfo[@BSG_KSSystemField_BuildType] = [BSG_KSSystemInfo buildType]; - sysInfo[@(BSG_KSSystemField_Memory)] = @{ - @(BSG_KSCrashField_Free): @(bsg_ksmachfreeMemory()), - @(BSG_KSCrashField_Usable): @(bsg_ksmachusableMemory()), - @(BSG_KSSystemField_Size): [self int64Sysctl:@"hw.memsize"] + sysInfo[@BSG_KSSystemField_Memory] = @{ + @BSG_KSCrashField_Free: @(bsg_ksmachfreeMemory()), + @BSG_KSCrashField_Usable: @(bsg_ksmachusableMemory()), + @BSG_KSSystemField_Size: [self int64Sysctl:@"hw.memsize"] }; +#if TARGET_OS_OSX || TARGET_OS_MACCATALYST + // https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment + int proc_translated = 0; + size_t size = sizeof(proc_translated); + if (!sysctlbyname("sysctl.proc_translated", &proc_translated, &size, NULL, 0) && proc_translated) { + sysInfo[@BSG_KSSystemField_Translated] = @YES; + } +#endif + NSDictionary *statsInfo = [[BSG_KSCrash sharedInstance] captureAppStats]; sysInfo[@BSG_KSCrashField_AppStats] = statsInfo; return sysInfo; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSDynamicLinker.c b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSDynamicLinker.c index e3bae02846..d31812ac59 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSDynamicLinker.c +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSDynamicLinker.c @@ -62,9 +62,13 @@ bool bsg_ksdldladdr(const uintptr_t address, Dl_info *const info) { if (image == NULL) { return false; } - const uintptr_t addressWithSlide = address - image->slide; + if (address < (uintptr_t)image->slide) { + return false; + } + const uintptr_t addressWithSlide = address - (uintptr_t)image->slide; const uintptr_t segmentBase = - bsg_mach_headers_image_at_base_of_image_index(image->header) + image->slide; + bsg_mach_headers_image_at_base_of_image_index(image->header) + + (uintptr_t)image->slide; if (segmentBase == 0) { return false; } @@ -102,7 +106,7 @@ bool bsg_ksdldladdr(const uintptr_t address, Dl_info *const info) { } if (bestMatch != NULL) { info->dli_saddr = - (void *)(bestMatch->n_value + image->slide); + (void *)(bestMatch->n_value + (uintptr_t)image->slide); info->dli_sname = (char *)((intptr_t)stringTable + (intptr_t)bestMatch->n_un.n_strx); if (*info->dli_sname == '_') { diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSFileUtils.c b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSFileUtils.c index fcbeec9603..812e17b107 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSFileUtils.c +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSFileUtils.c @@ -54,7 +54,7 @@ bool bsg_ksfuwriteBytesToFD(const int fd, const char *const bytes, // function retries with the remaining bytes until all bytes are written, // handling potential error cases as needed. while (bytesRemaining > 0) { - bytesWritten = write(fd, unwrittenBytes, bytesRemaining); + bytesWritten = write(fd, unwrittenBytes, (size_t)bytesRemaining); if (bytesWritten == -1) { // Retry as-is if a signal interrupt occurred, as its a recoverable // error. Otherwise exit early as the file descriptor cannot be written diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSJSONCodec.c b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSJSONCodec.c index 4619bd3974..e5059ce6f6 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSJSONCodec.c +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSJSONCodec.c @@ -105,7 +105,7 @@ static size_t uint64_to_string(uint64_t value, char* dst) { char buff[MAX_UINT64_DIGITS+1]; buff[sizeof(buff)-1] = 0; - int index = sizeof(buff) - 2; + size_t index = sizeof(buff) - 2; for(;;) { buff[index] = (value%10) + '0'; value /= 10; @@ -129,9 +129,9 @@ static size_t uint64_to_string(uint64_t value, char* dst) { static size_t int64_to_string(int64_t value, char* dst) { if (value < 0) { dst[0] = '-'; - return uint64_to_string(-value, dst+1) + 1; + return uint64_to_string((uint64_t)-value, dst+1) + 1; } - return uint64_to_string(value, dst); + return uint64_to_string((uint64_t)value, dst); } /** @@ -170,7 +170,7 @@ static size_t positive_double_to_string(const double value, char* dst, const int } // log10() is a compiler intrinsic. - int exponent = log10(value); + int exponent = (int)log10(value); // Values < 1.0 must subtract 1 from exponent to handle zero wraparound. if (value < 1.0) { exponent--; @@ -187,9 +187,9 @@ static size_t positive_double_to_string(const double value, char* dst, const int // Put all of the digits we'll use into an integer. double digits_and_remainder = normalized * pow(10, max_sig_digits-1); - uint64_t digits = digits_and_remainder; + uint64_t digits = (uint64_t)digits_and_remainder; // Also round up if necessary (note: 0.5 is exact in both binary and decimal). - if (digits_and_remainder - digits >= 0.5) { + if (digits_and_remainder - (double)digits >= 0.5) { digits++; // Special case: Adding one bumps us to next magnitude. if (digits >= (uint64_t)pow(10, max_sig_digits)) { @@ -204,7 +204,7 @@ static size_t positive_double_to_string(const double value, char* dst, const int digits /= 10; } // Extract the single-digit whole part. - dst[0] = digits + '0'; + dst[0] = (char)digits + '0'; dst[1] = '.'; // Strip off trailing zeroes, and also the '.' if there is no fractional part. @@ -232,7 +232,7 @@ static size_t positive_double_to_string(const double value, char* dst, const int *dst = 0; } - return dst - orig_dst; + return (size_t)(dst - orig_dst); } /** @@ -346,7 +346,7 @@ int bsg_ksjsoncodec_i_appendEscapedString( if ((unsigned char)*src < ' ') { unsigned int last = *src % 16; - unsigned int first = (*src - last) / 16; + unsigned int first = ((unsigned int)*src - last) / 16; *dst++ = '\\'; *dst++ = 'u'; @@ -512,7 +512,7 @@ int bsg_ksjsonaddUIntegerElement(BSG_KSJSONEncodeContext *const context, unlikely_if(result != BSG_KSJSON_OK) { return result; } char buff[30]; uint64_to_string(value, buff); - return addJSONData(context, buff, (int)strlen(buff)); + return addJSONData(context, buff, strlen(buff)); } int bsg_ksjsonaddJSONElement(BSG_KSJSONEncodeContext *const context, diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSJSONCodecObjC.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSJSONCodecObjC.h index d1861a302d..c790529fa5 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSJSONCodecObjC.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSJSONCodecObjC.h @@ -80,8 +80,6 @@ typedef NS_OPTIONS(NSUInteger, BSG_KSJSONDecodeOption) { * * @param JSONData The UTF-8 data to decode. * - * @param options Options for how to decode the data. - * * @param error Place to store any error that occurs (nil = ignore). Will be * set to nil on success. * @@ -89,7 +87,6 @@ typedef NS_OPTIONS(NSUInteger, BSG_KSJSONDecodeOption) { * option is not set, nil when an error occurs. */ + (id)decode:(NSData *)JSONData - options:(BSG_KSJSONDecodeOption)options error:(NSError **)error; @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSJSONCodecObjC.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSJSONCodecObjC.m index 0cc67cdaec..f114df9802 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSJSONCodecObjC.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSJSONCodecObjC.m @@ -232,7 +232,8 @@ - (void)dealloc { int bsg_ksjsoncodecobjc_i_onElement(BSG_KSJSONCodec *codec, NSString *name, id element) { - if (codec->_currentContainer == nil) { + id currentContainer = codec->_currentContainer; + if (!currentContainer) { codec.error = [NSError bsg_errorWithDomain:@"KSJSONCodecObjC" code:0 @@ -241,11 +242,10 @@ int bsg_ksjsoncodecobjc_i_onElement(BSG_KSJSONCodec *codec, NSString *name, return BSG_KSJSON_ERROR_INVALID_DATA; } - if ([codec->_currentContainer isKindOfClass:[NSMutableDictionary class]]) { - [(NSMutableDictionary *)codec->_currentContainer setValue:element - forKey:name]; + if ([currentContainer isKindOfClass:[NSMutableDictionary class]]) { + [(NSMutableDictionary *)currentContainer setValue:element forKey:name]; } else { - [(NSMutableArray *)codec->_currentContainer addObject:element]; + [(NSMutableArray *)currentContainer addObject:element]; } return BSG_KSJSON_OK; } @@ -297,10 +297,11 @@ int bsg_ksjsoncodecobjc_i_onNullElement(const char *const cName, NSString *name = stringFromCString(cName); BSG_KSJSONCodec *codec = (__bridge BSG_KSJSONCodec *)userData; + id currentContainer = codec->_currentContainer; if ((codec->_ignoreNullsInArrays && - [codec->_currentContainer isKindOfClass:[NSArray class]]) || + [currentContainer isKindOfClass:[NSArray class]]) || (codec->_ignoreNullsInObjects && - [codec->_currentContainer isKindOfClass:[NSDictionary class]])) { + [currentContainer isKindOfClass:[NSDictionary class]])) { return BSG_KSJSON_OK; } @@ -513,7 +514,6 @@ + (NSData *)encode:(id)object } + (id)decode:(NSData *)JSONData - options:(BSG_KSJSONDecodeOption)decodeOptions error:(NSError *__autoreleasing *)error { *error = nil; id result = nil; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMach.c b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMach.c index e6af66db9d..a850b56e66 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMach.c +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMach.c @@ -132,7 +132,7 @@ const char *bsg_ksmachexceptionName(const exception_type_t exceptionType) { return NULL; } -const char *bsg_ksmachkernelReturnCodeName(const unsigned long long returnCode) { +const char *bsg_ksmachkernelReturnCodeName(const kern_return_t returnCode) { switch (returnCode) { RETURN_NAME_FOR_ENUM(KERN_SUCCESS); RETURN_NAME_FOR_ENUM(KERN_INVALID_ADDRESS); @@ -510,7 +510,7 @@ double bsg_ksmachtimeDifferenceInSeconds(const uint64_t endTime, conversion = 1e-9 * (double)info.numer / (double)info.denom; } - return conversion * (endTime - startTime); + return conversion * (double)(endTime - startTime); } /** Check if the current process is being traced or not. diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMach.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMach.h index 765e85b5cd..d93a8889c3 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMach.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMach.h @@ -87,7 +87,7 @@ const char *bsg_ksmachexceptionName(exception_type_t exceptionType); * * @return The code's name or NULL if not found. */ -const char *bsg_ksmachkernelReturnCodeName(unsigned long long returnCode); +const char *bsg_ksmachkernelReturnCodeName(const kern_return_t returnCode); // ============================================================================ #pragma mark - Thread State Info - diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMachHeaders.c b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMachHeaders.c index 4b30496090..1a8f9f4723 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMachHeaders.c +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSMachHeaders.c @@ -206,7 +206,10 @@ BSG_Mach_Header_Info *bsg_mach_headers_image_at_address(const uintptr_t address) if (cmdPtr == 0) { continue; } - uintptr_t addressWSlide = address - img->slide; + if (address < (uintptr_t)img->slide) { + continue; + } + uintptr_t addressWSlide = address - (uintptr_t)img->slide; for (uint32_t iCmd = 0; iCmd < img->header->ncmds; iCmd++) { const struct load_command *loadCmd = (struct load_command *)cmdPtr; @@ -285,20 +288,20 @@ static uintptr_t bsg_mach_header_info_get_section_addr_named(const BSG_Mach_Head if (loadCmd->cmd == LC_SEGMENT) { const struct segment_command *segment = (void *)cmdPtr; char *sectionPtr = (void *)(cmdPtr + sizeof(*segment)); - for (uint32_t i = 0; i < segment->nsects; i++) { + for (uint32_t j = 0; j < segment->nsects; j++) { struct section *section = (void *)sectionPtr; if (strcmp(name, section->sectname) == 0) { - return section->addr + header->slide; + return section->addr + (uintptr_t)header->slide; } sectionPtr += sizeof(*section); } } else if (loadCmd->cmd == LC_SEGMENT_64) { const struct segment_command_64 *segment = (void *)cmdPtr; char *sectionPtr = (void *)(cmdPtr + sizeof(*segment)); - for (uint32_t i = 0; i < segment->nsects; i++) { + for (uint32_t j = 0; j < segment->nsects; j++) { struct section_64 *section = (void *)sectionPtr; if (strcmp(name, section->sectname) == 0) { - return (uintptr_t)section->addr + header->slide; + return (uintptr_t)section->addr + (uintptr_t)header->slide; } sectionPtr += sizeof(*section); } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Metadata/BugsnagMetadata+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Metadata/BugsnagMetadata+Private.h index c6e478966b..f1eece0674 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Metadata/BugsnagMetadata+Private.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Metadata/BugsnagMetadata+Private.h @@ -18,7 +18,7 @@ typedef void (^BugsnagObserverBlock)(BugsnagStateEvent *event); #pragma mark Properties -@property (readonly) NSMutableDictionary *dictionary; +@property (readonly, nonatomic) NSMutableDictionary *dictionary; #pragma mark Methods diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Metadata/BugsnagMetadata.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Metadata/BugsnagMetadata.m index 5d24e7cf85..c379cce4c0 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Metadata/BugsnagMetadata.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Metadata/BugsnagMetadata.m @@ -117,7 +117,7 @@ - (void)removeObserverWithBlock:(BugsnagObserverBlock _Nonnull)block { // MARK: - -- (instancetype)mutableCopyWithZone:(NSZone *)zone { +- (instancetype)mutableCopyWithZone:(__attribute__((unused)) NSZone *)zone { @synchronized(self) { NSMutableDictionary *dict = [self.dictionary mutableCopy]; return [[BugsnagMetadata alloc] initWithDictionary:dict]; @@ -216,9 +216,7 @@ - (void)clearMetadataFromSection:(NSString *)section withKey:(NSString *)key { @synchronized(self) { - if ([[[self dictionary] objectForKey:section] objectForKey:key]) { - [[[self dictionary] objectForKey:section] removeObjectForKey:key]; - } + [(NSMutableDictionary *)self.dictionary[section] removeObjectForKey:key]; } [self notifyObservers]; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagApp.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagApp.m index e4c023980f..3a1c916ab9 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagApp.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagApp.m @@ -7,6 +7,8 @@ // #import "BugsnagApp.h" + +#import "BSG_KSSystemInfo.h" #import "BugsnagKeys.h" #import "BugsnagConfiguration.h" #import "BugsnagCollections.h" @@ -18,7 +20,9 @@ */ NSDictionary *BSGParseAppMetadata(NSDictionary *event) { NSMutableDictionary *app = [NSMutableDictionary new]; - app[@"name"] = [event valueForKeyPath:@"system.CFBundleExecutable"]; + app[@"name"] = [event valueForKeyPath:@"system." BSG_KSSystemField_BundleExecutable]; + app[@"binaryArch"] = [event valueForKeyPath:@"system." BSG_KSSystemField_BinaryArch]; + app[@"runningOnRosetta"] = [event valueForKeyPath:@"system." BSG_KSSystemField_Translated]; return app; } @@ -70,7 +74,7 @@ - (NSDictionary *)toDict NSMutableDictionary *dict = [NSMutableDictionary new]; dict[@"bundleVersion"] = self.bundleVersion; dict[@"codeBundleId"] = self.codeBundleId; - dict[@"dsymUUIDs"] = self.dsymUuid ? @[self.dsymUuid] : nil; + dict[@"dsymUUIDs"] = BSGArrayWithObject(self.dsymUuid); dict[@"id"] = self.id; dict[@"releaseStage"] = self.releaseStage; dict[@"type"] = self.type; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagAppWithState+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagAppWithState+Private.h index 879899e90f..55d8d53567 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagAppWithState+Private.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagAppWithState+Private.h @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN + (BugsnagAppWithState *)appFromJson:(NSDictionary *)json; -+ (BugsnagAppWithState *)appWithDictionary:(NSDictionary *)event config:(BugsnagConfiguration *)config codeBundleId:(NSString *)codeBundleId; ++ (BugsnagAppWithState *)appWithDictionary:(NSDictionary *)event config:(BugsnagConfiguration *)config codeBundleId:(nullable NSString *)codeBundleId; - (NSDictionary *)toDict; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagBreadcrumb+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagBreadcrumb+Private.h index 906e92301e..230705598b 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagBreadcrumb+Private.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagBreadcrumb+Private.h @@ -12,8 +12,6 @@ NS_ASSUME_NONNULL_BEGIN @interface BugsnagBreadcrumb () -+ (NSArray *)breadcrumbArrayFromJson:(NSArray *)json; - + (nullable instancetype)breadcrumbFromDict:(NSDictionary *)dict; + (nullable instancetype)breadcrumbWithBlock:(void (^)(BugsnagBreadcrumb *))block; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagBreadcrumb.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagBreadcrumb.m index 5027d11537..d0b82435cd 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagBreadcrumb.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagBreadcrumb.m @@ -201,18 +201,6 @@ + (instancetype)breadcrumbWithBlock:(BSGBreadcrumbConfiguration)block { return nil; } -+ (NSArray *)breadcrumbArrayFromJson:(NSArray *)json { - NSMutableArray *data = [NSMutableArray new]; - - for (NSDictionary *dict in json) { - BugsnagBreadcrumb *crumb = [BugsnagBreadcrumb breadcrumbFromDict:dict]; - if (crumb) { - [data addObject:crumb]; - } - } - return data; -} - + (instancetype)breadcrumbFromDict:(NSDictionary *)dict { BOOL isValidCrumb = [dict[BSGKeyType] isKindOfClass:[NSString class]] && [dict[BSGKeyTimestamp] isKindOfClass:[NSString class]] diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError+Private.h index af5ef98cc8..ec65da6989 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError+Private.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError+Private.h @@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN NSString *BSGParseErrorClass(NSDictionary *error, NSString *errorType); -NSString *BSGParseErrorMessage(NSDictionary *report, NSDictionary *error, NSString *errorType); +NSString * _Nullable BSGParseErrorMessage(NSDictionary *report, NSDictionary *error, NSString *errorType); BSGErrorType BSGParseErrorType(NSString *errorType); diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError.m index 606fb3de16..1f302a0c93 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError.m @@ -132,7 +132,7 @@ + (BugsnagError *)errorFromJson:(NSDictionary *)json { error.errorClass = json[BSGKeyErrorClass]; error.errorMessage = json[BSGKeyMessage]; error.stacktrace = data; - error.typeString = json[BSGKeyType]; + error.typeString = json[BSGKeyType] ?: BSGErrorTypeStringCocoa; return error; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent+Private.h index e922277941..989987a576 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent+Private.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent+Private.h @@ -18,21 +18,21 @@ NS_ASSUME_NONNULL_BEGIN @property (readwrite, copy, nullable, nonatomic) NSDictionary *customException; /// Number of frames to discard at the top of the generated stacktrace. Stacktraces from raised exceptions are unaffected. -@property NSUInteger depth; +@property (nonatomic) NSUInteger depth; /// A unique hash identifying this device for the application or vendor. @property (readwrite, copy, nullable, nonatomic) NSString *deviceAppHash; /// The release stages used to notify at the time this report is captured. -@property (readwrite, copy, nullable) NSArray *enabledReleaseStages; +@property (readwrite, copy, nullable, nonatomic) NSArray *enabledReleaseStages; /// Raw error data added to metadata. -@property (readwrite, copy, nullable) NSDictionary *error; +@property (readwrite, copy, nullable, nonatomic) NSDictionary *error; /// The event state (whether the error is handled/unhandled.) @property (readwrite, nonatomic) BugsnagHandledState *handledState; -@property (strong, nonatomic) BugsnagMetadata *metadata; +@property (strong, nullable, nonatomic) BugsnagMetadata *metadata; /// The release stage of the application @property (readwrite, copy, nullable, nonatomic) NSString *releaseStage; @@ -42,16 +42,16 @@ NS_ASSUME_NONNULL_BEGIN /// An array of string representations of BSGErrorType describing the types of stackframe / stacktrace in this error. @property (readonly, nonatomic) NSArray *stacktraceTypes; -@property (readwrite, nonatomic, nonnull) BugsnagUser *user; +@property (readwrite, nonnull, nonatomic) BugsnagUser *user; -- (instancetype)initWithApp:(nullable BugsnagAppWithState *)app - device:(nullable BugsnagDeviceWithState *)device +- (instancetype)initWithApp:(BugsnagAppWithState *)app + device:(BugsnagDeviceWithState *)device handledState:(BugsnagHandledState *)handledState - user:(nullable BugsnagUser *)user - metadata:(nullable BugsnagMetadata *)metadata + user:(BugsnagUser *)user + metadata:(BugsnagMetadata *)metadata breadcrumbs:(NSArray *)breadcrumbs errors:(NSArray *)errors - threads:(nullable NSArray *)threads + threads:(NSArray *)threads session:(nullable BugsnagSession *)session; - (instancetype)initWithJson:(NSDictionary *)json; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent.m index b423ab18d8..05aab39eed 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent.m @@ -39,8 +39,6 @@ #import "BugsnagUser+Private.h" -static NSString *const DEFAULT_EXCEPTION_TYPE = @"cocoa"; - id BSGLoadConfigValue(NSDictionary *report, NSString *valueName) { NSString *keypath = [NSString stringWithFormat:@"user.config.%@", valueName]; NSString *fallbackKeypath = [NSString stringWithFormat:@"user.config.config.%@", valueName]; @@ -184,18 +182,45 @@ - (instancetype)initWithApp:(BugsnagAppWithState *)app - (instancetype)initWithJson:(NSDictionary *)json { if (self = [super init]) { - _app = [BugsnagAppWithState appFromJson:json[BSGKeyApp]]; - _breadcrumbs = BSGArrayMap(json[BSGKeyBreadcrumbs], ^id (NSDictionary *json) { return [BugsnagBreadcrumb breadcrumbFromDict:json]; }); - _context = json[BSGKeyContext]; - _device = [BugsnagDeviceWithState deviceFromJson:json[BSGKeyDevice]]; - _error = json[BSGKeyMetadata][BSGKeyError]; - _errors = BSGArrayMap(json[BSGKeyExceptions], ^id (NSDictionary *json) { return [BugsnagError errorFromJson:json]; }); - _groupingHash = json[BSGKeyGroupingHash]; + _app = BSGDeserializeObject(json[BSGKeyApp], ^id _Nullable(NSDictionary * _Nonnull dict) { + return [BugsnagAppWithState appFromJson:dict]; + }) ?: [[BugsnagAppWithState alloc] init]; + + _breadcrumbs = BSGDeserializeArrayOfObjects(json[BSGKeyBreadcrumbs], ^id _Nullable(NSDictionary * _Nonnull dict) { + return [BugsnagBreadcrumb breadcrumbFromDict:dict]; + }) ?: @[]; + + _context = BSGDeserializeString(json[BSGKeyContext]); + + _device = BSGDeserializeObject(json[BSGKeyDevice], ^id _Nullable(NSDictionary * _Nonnull dict) { + return [BugsnagDeviceWithState deviceFromJson:dict]; + }) ?: [[BugsnagDeviceWithState alloc] init]; + + _error = BSGDeserializeDict(json[BSGKeyMetadata][BSGKeyError]); + + _errors = BSGDeserializeArrayOfObjects(json[BSGKeyExceptions], ^id _Nullable(NSDictionary * _Nonnull dict) { + return [BugsnagError errorFromJson:dict]; + }) ?: @[]; + + _groupingHash = BSGDeserializeString(json[BSGKeyGroupingHash]); + _handledState = [BugsnagHandledState handledStateFromJson:json]; - _metadata = [[BugsnagMetadata alloc] initWithDictionary:json[BSGKeyMetadata]]; - _session = [BugsnagSession fromJson:json[BSGKeySession]]; - _threads = BSGArrayMap(json[BSGKeyThreads], ^id (NSDictionary *json) { return [BugsnagThread threadFromJson:json]; }); - _user = [[BugsnagUser alloc] initWithDictionary:json[BSGKeyUser]]; + + _metadata = BSGDeserializeObject(json[BSGKeyMetadata], ^id _Nullable(NSDictionary * _Nonnull dict) { + return [[BugsnagMetadata alloc] initWithDictionary:dict]; + }) ?: [[BugsnagMetadata alloc] init]; + + _session = BSGDeserializeObject(json[BSGKeySession], ^id _Nullable(NSDictionary * _Nonnull dict) { + return [BugsnagSession fromJson:dict]; + }); + + _threads = BSGDeserializeArrayOfObjects(json[BSGKeyThreads], ^id _Nullable(NSDictionary * _Nonnull dict) { + return [BugsnagThread threadFromJson:dict]; + }) ?: @[]; + + _user = BSGDeserializeObject(json[BSGKeyUser], ^id _Nullable(NSDictionary * _Nonnull dict) { + return [[BugsnagUser alloc] initWithDictionary:dict]; + }) ?: [[BugsnagUser alloc] init]; } return self; } @@ -278,10 +303,9 @@ - (instancetype)initWithKSCrashData:(NSDictionary *)event { } else { depth = 0; } - BugsnagSession *session; - if (event[BSGKeyUser][@"id"]) { - session = [[BugsnagSession alloc] initWithDictionary:event[BSGKeyUser]]; - } + BugsnagSession *session = BSGDeserializeObject(event[BSGKeyUser], ^id _Nullable(NSDictionary * _Nonnull userDict) { + return userDict[@"id"] ? [[BugsnagSession alloc] initWithDictionary:userDict] : nil; + }); // generate threads/error info NSArray *binaryImages = event[@"binary_images"]; @@ -302,7 +326,7 @@ - (instancetype)initWithKSCrashData:(NSDictionary *)event { NSArray *errors = @[[[BugsnagError alloc] initWithEvent:event errorReportingThread:errorReportingThread]]; if (errorReportingThread.crashInfoMessage) { - [errors[0] updateWithCrashInfoMessage:errorReportingThread.crashInfoMessage]; + [errors[0] updateWithCrashInfoMessage:(NSString * _Nonnull)errorReportingThread.crashInfoMessage]; error[@"crashInfo"] = errorReportingThread.crashInfoMessage; } @@ -320,16 +344,21 @@ - (instancetype)initWithKSCrashData:(NSDictionary *)event { handledState.unhandledOverridden = isUnhandledOverridden; } - NSMutableDictionary *userAtCrash = [self parseOnCrashData:event]; - if (userAtCrash != nil) { - for (NSString *section in [userAtCrash allKeys]) { - [metadata addMetadata:userAtCrash[section] toSection:section]; + [[self parseOnCrashData:event] enumerateKeysAndObjectsUsingBlock:^(id key, id obj, __attribute__((unused)) BOOL *stop) { + if ([key isKindOfClass:[NSString class]] && + [obj isKindOfClass:[NSDictionary class]]) { + [metadata addMetadata:obj toSection:key]; } - } + }]; + NSString *deviceAppHash = [event valueForKeyPath:@"system.device_app_hash"]; BugsnagDeviceWithState *device = [BugsnagDeviceWithState deviceWithKSCrashReport:event]; BugsnagUser *user = [self parseUser:event deviceAppHash:deviceAppHash deviceId:device.id]; - BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithDictionaryRepresentation:[event valueForKeyPath:@"user.config"]]; + + NSDictionary *configDict = [event valueForKeyPath:@"user.config"]; + BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithDictionaryRepresentation: + [configDict isKindOfClass:[NSDictionary class]] ? configDict : @{}]; + BugsnagAppWithState *app = [BugsnagAppWithState appWithDictionary:event config:config codeBundleId:self.codeBundleId]; BugsnagEvent *obj = [self initWithApp:app device:device @@ -356,60 +385,25 @@ - (instancetype)initWithKSCrashData:(NSDictionary *)event { * the Bugsnag Error API JSON schema, with the exception that they are * wrapped in a KSCrash JSON object. * - * @param event a KSCrash report + * @param crashReport a KSCrash report * * @return a BugsnagEvent containing the parsed information */ -- (instancetype)initWithUserData:(NSDictionary *)event { - NSDictionary *bugsnagPayload = [event valueForKeyPath:@"user.event"]; - // deserialize exceptions - NSArray *errorDicts = bugsnagPayload[BSGKeyExceptions]; - NSMutableArray *errors = [NSMutableArray new]; - - if (errorDicts != nil) { - for (NSDictionary *dict in errorDicts) { - BugsnagError *error = [BugsnagError errorFromJson:dict]; - - if (error != nil) { - [errors addObject:error]; - } - } +- (instancetype)initWithUserData:(NSDictionary *)crashReport { + NSDictionary *json = BSGDeserializeDict([crashReport valueForKeyPath:@"user.event"]); + if (!json || !(self = [self initWithJson:json])) { + return nil; } + _apiKey = BSGDeserializeString(json[BSGKeyApiKey]); + _context = BSGDeserializeString(json[BSGKeyContext]); + _groupingHash = BSGDeserializeString(json[BSGKeyGroupingHash]); + _error = [self getMetadataFromSection:BSGKeyError]; - // deserialize threads - NSArray *threadDicts = bugsnagPayload[BSGKeyThreads]; - NSMutableArray *threads = [NSMutableArray new]; - - if (threadDicts != nil) { - for (NSDictionary *dict in threadDicts) { - BugsnagThread *thread = [BugsnagThread threadFromJson:dict]; - - if (thread != nil) { - [threads addObject:thread]; - } - } + if (_errors.count) { + BugsnagError *error = _errors[0]; + _customException = BSGParseCustomException(crashReport, error.errorClass, error.errorMessage); } - BugsnagSession *session = [BugsnagSession fromJson:bugsnagPayload[BSGKeySession]]; - - BugsnagEvent *obj = [self initWithApp:[BugsnagAppWithState appFromJson:bugsnagPayload[BSGKeyApp]] - device:[BugsnagDeviceWithState deviceFromJson:bugsnagPayload[BSGKeyDevice]] - handledState:[BugsnagHandledState handledStateFromJson:bugsnagPayload] - user:[[BugsnagUser alloc] initWithDictionary:bugsnagPayload[BSGKeyUser]] - metadata:[[BugsnagMetadata alloc] initWithDictionary:bugsnagPayload[BSGKeyMetadata]] - breadcrumbs:[BugsnagBreadcrumb breadcrumbArrayFromJson:bugsnagPayload[BSGKeyBreadcrumbs]] - errors:errors - threads:threads - session:session]; - obj.apiKey = bugsnagPayload[BSGKeyApiKey]; - obj.context = bugsnagPayload[BSGKeyContext]; - obj.groupingHash = bugsnagPayload[BSGKeyGroupingHash]; - obj.error = [self getMetadataFromSection:BSGKeyError]; - - if ([errors count] > 0) { - BugsnagError *err = errors[0]; - obj.customException = BSGParseCustomException(event, err.errorClass, err.errorMessage); - } - return obj; + return self; } - (NSMutableDictionary *)parseOnCrashData:(NSDictionary *)report { @@ -460,7 +454,7 @@ - (void)setApiKey:(NSString *)apiKey { } - (BOOL)shouldBeSent { - return [self.enabledReleaseStages containsObject:self.releaseStage] || + return [self.enabledReleaseStages containsObject:self.releaseStage ?: @""] || (self.enabledReleaseStages.count == 0); } @@ -490,14 +484,6 @@ - (void)setSeverity:(BSGSeverity)severity { // MARK: - User // ============================================================================= -/** - * The current user - */ -@synthesize user = _user; -- (BugsnagUser *_Nonnull)user { - return _user; -} - /** * Set user metadata * @@ -545,9 +531,9 @@ - (NSDictionary *)toJsonWithRedactedKeys:(NSSet *)redactedKeys { event[BSGKeyExceptions] = ({ NSMutableArray *array = [NSMutableArray array]; - [self.errors enumerateObjectsUsingBlock:^(BugsnagError *error, NSUInteger idx, BOOL *stop) { + [self.errors enumerateObjectsUsingBlock:^(BugsnagError *error, NSUInteger idx, __attribute__((unused)) BOOL *stop) { if (self.customException != nil && idx == 0) { - [array addObject:self.customException]; + [array addObject:(NSDictionary * _Nonnull)self.customException]; } else { [array addObject:[error toDictionary]]; } @@ -602,7 +588,15 @@ - (NSDictionary *)toJsonWithRedactedKeys:(NSSet *)redactedKeys { event[BSGKeyUser] = [self.user toJson]; if (self.session) { - event[BSGKeySession] = [self generateSessionDict]; + // Different from the payload returned by [BugsnagSession toDictionary] or [BugsnagSession toJson] + event[BSGKeySession] = @{ + BSGKeyId: self.session.id ?: @"", + @"startedAt": [BSG_RFC3339DateTool stringFromDate:self.session.startedAt] ?: @"", + @"events": @{ + @"handled": @(self.session.handledCount), + @"unhandled": @(self.session.unhandledCount) + } + }; } return event; } @@ -613,7 +607,7 @@ - (NSMutableDictionary *)sanitiseMetadata:(NSMutableDictionary *)metadata redact metadata[sectionKey] = [metadata[sectionKey] mutableCopy]; } else { NSString *message = [NSString stringWithFormat:@"Expected an NSDictionary but got %@ %@", - NSStringFromClass([metadata[sectionKey] class]), metadata[sectionKey]]; + NSStringFromClass([(id _Nonnull)metadata[sectionKey] class]), metadata[sectionKey]]; bsg_log_err(@"%@", message); // Leave an indication of the error in the payload for diagnosis metadata[sectionKey] = [@{@"bugsnag.error": message} mutableCopy]; @@ -661,20 +655,6 @@ - (BOOL)isRedactedKey:(NSString *)key redactedKeys:(NSSet *)redactedKeys { return false; } -- (NSDictionary *)generateSessionDict { - NSDictionary *events = @{ - @"handled": @(self.session.handledCount), - @"unhandled": @(self.session.unhandledCount) - }; - - NSDictionary *sessionJson = @{ - BSGKeyId: self.session.id, - @"startedAt": [BSG_RFC3339DateTool stringFromDate:self.session.startedAt], - @"events": events - }; - return sessionJson; -} - - (BOOL)unhandled { return self.handledState.unhandled; } @@ -735,18 +715,14 @@ - (void)clearMetadataFromSection:(NSString *_Nonnull)sectionName [stacktraceTypes addObject:BSGSerializeErrorType(error.type)]; for (BugsnagStackframe *stackframe in error.stacktrace) { - if (stackframe.type) { - [stacktraceTypes addObject:stackframe.type]; - } + BSGSetAddIfNonnull(stacktraceTypes, stackframe.type); } } for (BugsnagThread *thread in self.threads) { [stacktraceTypes addObject:BSGSerializeThreadType(thread.type)]; for (BugsnagStackframe *stackframe in thread.stacktrace) { - if (stackframe.type) { - [stacktraceTypes addObject:stackframe.type]; - } + BSGSetAddIfNonnull(stacktraceTypes, stackframe.type); } } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.h index 70c44f19f7..0076c9250d 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.h @@ -12,10 +12,10 @@ NS_ASSUME_NONNULL_BEGIN @interface BugsnagNotifier : NSObject -@property NSString *name; -@property NSString *version; -@property NSString *url; -@property NSMutableArray *dependencies; +@property (copy, nonatomic) NSString *name; +@property (copy, nonatomic) NSString *version; +@property (copy, nonatomic) NSString *url; +@property (nonatomic) NSMutableArray *dependencies; - (NSDictionary *)toDict; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m index bbe01e5e8f..5c12248cd7 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m @@ -23,7 +23,7 @@ - (instancetype)init { #else self.name = @"Bugsnag Objective-C"; #endif - self.version = @"6.8.4"; + self.version = @"6.9.0"; self.url = @"https://github.com/bugsnag/bugsnag-cocoa"; self.dependencies = [NSMutableArray new]; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSession+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSession+Private.h index 348d167e33..a204f909eb 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSession+Private.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSession+Private.h @@ -16,20 +16,20 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark Initializers -+ (instancetype)fromJson:(NSDictionary *)json; ++ (nullable instancetype)fromJson:(NSDictionary *)json; -- (instancetype)initWithDictionary:(NSDictionary *)dict; +- (nullable instancetype)initWithDictionary:(NSDictionary *)dict; - (instancetype)initWithId:(NSString *)sessionId startDate:(NSDate *)startDate - user:(nullable BugsnagUser *)user + user:(BugsnagUser *)user autoCaptured:(BOOL)autoCaptured app:(BugsnagApp *)app device:(BugsnagDevice *)device; - (instancetype)initWithId:(NSString *)sessionId startDate:(NSDate *)startDate - user:(nullable BugsnagUser *)user + user:(BugsnagUser *)user handledCount:(NSUInteger)handledCount unhandledCount:(NSUInteger)unhandledCount app:(BugsnagApp *)app @@ -37,13 +37,13 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark Properties -@property (readonly) BOOL autoCaptured; +@property (readonly, nonatomic) BOOL autoCaptured; -@property NSUInteger handledCount; +@property (nonatomic) NSUInteger handledCount; -@property (getter=isStopped) BOOL stopped; +@property (getter=isStopped, nonatomic) BOOL stopped; -@property NSUInteger unhandledCount; +@property (nonatomic) NSUInteger unhandledCount; @property (readwrite, nonnull, nonatomic) BugsnagUser *user; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSession.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSession.m index c183b16a60..08bc860b7a 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSession.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSession.m @@ -23,12 +23,12 @@ @implementation BugsnagSession -- (instancetype)initWithId:(NSString *_Nonnull)sessionId - startDate:(NSDate *_Nonnull)startDate - user:(BugsnagUser *_Nullable)user +- (instancetype)initWithId:(NSString *)sessionId + startDate:(NSDate *)startDate + user:(BugsnagUser *)user autoCaptured:(BOOL)autoCaptured - app:(BugsnagApp *_Nonnull)app - device:(BugsnagDevice *_Nonnull)device { + app:(BugsnagApp *)app + device:(BugsnagDevice *)device { if (self = [super init]) { _id = sessionId; _startedAt = [startDate copy]; @@ -40,48 +40,58 @@ - (instancetype)initWithId:(NSString *_Nonnull)sessionId return self; } -+ (instancetype)fromJson:(NSDictionary *)json { ++ (nullable instancetype)fromJson:(NSDictionary *)json { if (!json) { return nil; } - BugsnagSession *session = [BugsnagSession new]; - session.id = json[kBugsnagSessionId]; - - NSString *timestamp = json[kBugsnagStartedAt]; - - if (timestamp != nil) { - session.startedAt = [BSG_RFC3339DateTool dateFromString:timestamp]; + NSString *sessionId = BSGDeserializeString(json[kBugsnagSessionId]); + if (!sessionId) { + return nil; } NSDictionary *events = json[@"events"]; - - if (events != nil) { - session.unhandledCount = [events[@"unhandled"] unsignedIntegerValue]; - session.handledCount = [events[@"handled"] unsignedIntegerValue]; - } - return session; + return [[BugsnagSession alloc] initWithId:sessionId + startDate:BSGDeserializeDate(json[kBugsnagStartedAt]) ?: [NSDate date] + user:[[BugsnagUser alloc] init] + handledCount:[events[@"handled"] unsignedIntegerValue] + unhandledCount:[events[@"unhandled"] unsignedIntegerValue] + app:[[BugsnagApp alloc] init] + device:[[BugsnagDevice alloc] init]]; } -- (instancetype)initWithDictionary:(NSDictionary *_Nonnull)dict { +- (nullable instancetype)initWithDictionary:(NSDictionary *)dict { + NSString *sessionId = BSGDeserializeString(dict[kBugsnagSessionId]); + if (!sessionId) { + return nil; + } if (self = [super init]) { - _id = dict[kBugsnagSessionId]; + _id = sessionId; _unhandledCount = [dict[kBugsnagUnhandledCount] unsignedIntegerValue]; _handledCount = [dict[kBugsnagHandledCount] unsignedIntegerValue]; - _startedAt = [BSG_RFC3339DateTool dateFromString:dict[kBugsnagStartedAt]]; - _user = [[BugsnagUser alloc] initWithDictionary:dict[kBugsnagUser]]; - _app = [BugsnagApp deserializeFromJson:dict[BSGKeyApp]]; - _device = [BugsnagDevice deserializeFromJson:dict[BSGKeyDevice]]; + _startedAt = BSGDeserializeDate(dict[kBugsnagStartedAt]) ?: [NSDate date]; + + _user = BSGDeserializeObject(dict[kBugsnagUser], ^id _Nullable(NSDictionary * _Nonnull json) { + return [[BugsnagUser alloc] initWithDictionary:json]; + }) ?: [[BugsnagUser alloc] initWithDictionary:@{}]; + + _app = BSGDeserializeObject(dict[BSGKeyApp], ^id _Nullable(NSDictionary * _Nonnull json) { + return [BugsnagApp deserializeFromJson:json]; + }) ?: [[BugsnagApp alloc] init]; + + _device = BSGDeserializeObject(dict[BSGKeyDevice], ^id _Nullable(NSDictionary * _Nonnull json) { + return [BugsnagDevice deserializeFromJson:json]; + }) ?: [[BugsnagDevice alloc] init]; } return self; } -- (_Nonnull instancetype)initWithId:(NSString *_Nonnull)sessionId - startDate:(NSDate *_Nonnull)startDate - user:(BugsnagUser *_Nullable)user +- (_Nonnull instancetype)initWithId:(NSString *)sessionId + startDate:(NSDate *)startDate + user:(BugsnagUser *)user handledCount:(NSUInteger)handledCount unhandledCount:(NSUInteger)unhandledCount - app:(BugsnagApp *_Nonnull)app - device:(BugsnagDevice *_Nonnull)device { + app:(BugsnagApp *)app + device:(BugsnagDevice *)device { if (self = [super init]) { _id = sessionId; _startedAt = startDate; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSessionTrackingPayload.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSessionTrackingPayload.h index 17420d96ab..b89d263052 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSessionTrackingPayload.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSessionTrackingPayload.h @@ -14,7 +14,7 @@ @interface BugsnagSessionTrackingPayload : NSObject -@property NSArray *sessions; +@property (nonatomic) NSArray *sessions; - (instancetype)initWithSessions:(NSArray *)sessions config:(BugsnagConfiguration *)config diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe+Private.h index 92228afa73..7fe0a5592d 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe+Private.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe+Private.h @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN @interface BugsnagStackframe () -+ (NSArray *)stackframesWithBacktrace:(uintptr_t *)backtrace length:(int)length; ++ (NSArray *)stackframesWithBacktrace:(uintptr_t *)backtrace length:(NSUInteger)length; + (NSArray *)stackframesWithCallStackReturnAddresses:(NSArray *)callStackReturnAddresses; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe.m index 7dfde07e73..b877df3f33 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe.m @@ -92,10 +92,10 @@ + (BugsnagStackframe *)frameFromDict:(NSDictionary *)dict } } -+ (NSArray *)stackframesWithBacktrace:(uintptr_t *)backtrace length:(int)length { ++ (NSArray *)stackframesWithBacktrace:(uintptr_t *)backtrace length:(NSUInteger)length { NSMutableArray *frames = [NSMutableArray array]; - for (int i = 0; i < length; i++) { + for (NSUInteger i = 0; i < length; i++) { uintptr_t address = backtrace[i]; if (address == 1) { // We sometimes get a frame address of 0x1 at the bottom of the call stack. @@ -128,9 +128,9 @@ + (BugsnagStackframe *)frameFromDict:(NSDictionary *)dict } + (NSArray *)stackframesWithCallStackReturnAddresses:(NSArray *)callStackReturnAddresses { - int length = (int)callStackReturnAddresses.count; + NSUInteger length = callStackReturnAddresses.count; uintptr_t addresses[length]; - for (int i = 0; i < length; i++) { + for (NSUInteger i = 0; i < length; i++) { addresses[i] = (uintptr_t)callStackReturnAddresses[i].unsignedLongLongValue; } return [BugsnagStackframe stackframesWithBacktrace:addresses length:length]; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStateEvent.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStateEvent.h index 29c423390a..5b471b45f8 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStateEvent.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStateEvent.h @@ -16,12 +16,11 @@ static NSString *const kStateEventUser = @"UserUpdate"; @interface BugsnagStateEvent : NSObject -@property NSString *type; +@property (copy, nonatomic) NSString *type; -@property id data; +@property (nullable, nonatomic) id data; -- (instancetype)initWithName:(NSString *)name - data:(id)data; +- (instancetype)initWithName:(NSString *)name data:(nullable id)data; @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread+Private.h index 42b9481a3f..7d0f32f8ee 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread+Private.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread+Private.h @@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN + (instancetype)threadFromJson:(NSDictionary *)json; -@property (readonly) NSString *crashInfoMessage; +@property (readonly, nullable, nonatomic) NSString *crashInfoMessage; @property (readwrite, nonatomic) BOOL errorReportingThread; @@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN depth:(NSUInteger)depth errorType:(nullable NSString *)errorType; -+ (NSMutableArray *)serializeThreads:(NSArray *)threads; ++ (NSMutableArray *)serializeThreads:(nullable NSArray *)threads; + (NSMutableArray *)threadsFromArray:(NSArray *)threads binaryImages:(NSArray *)binaryImages diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread+Recording.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread+Recording.m index 3fb1494b0a..48b9f6ad26 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread+Recording.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread+Recording.m @@ -33,14 +33,14 @@ static void resume_threads() { #define kMaxAddresses 150 // same as BSG_kMaxBacktraceDepth struct backtrace_t { - int length; + NSUInteger length; uintptr_t addresses[kMaxAddresses]; }; static void backtrace_for_thread(thread_t thread, struct backtrace_t *output) { - BSG_STRUCT_MCONTEXT_L machineContext = {0}; + BSG_STRUCT_MCONTEXT_L machineContext = {{0}}; if (bsg_ksmachthreadState(thread, &machineContext)) { - output->length = bsg_ksbt_backtraceThreadState(&machineContext, output->addresses, 0, kMaxAddresses); + output->length = (NSUInteger)bsg_ksbt_backtraceThreadState(&machineContext, output->addresses, 0, kMaxAddresses); } else { output->length = 0; } @@ -53,8 +53,8 @@ @implementation BugsnagThread (Recording) + (NSArray *)allThreads:(BOOL)allThreads callStackReturnAddresses:(NSArray *)callStackReturnAddresses { struct backtrace_t backtrace; - backtrace.length = (int)MIN(callStackReturnAddresses.count, kMaxAddresses); - for (int i = 0; i < backtrace.length; i++) { + backtrace.length = MIN(callStackReturnAddresses.count, kMaxAddresses); + for (NSUInteger i = 0; i < (NSUInteger)backtrace.length; i++) { backtrace.addresses[i] = (uintptr_t)callStackReturnAddresses[i].unsignedLongLongValue; } if (allThreads) { @@ -81,7 +81,7 @@ @implementation BugsnagThread (Recording) struct backtrace_t backtraces[threadCount]; - for (int i = 0; i < threadCount; i++) { + for (mach_msg_type_number_t i = 0; i < threadCount; i++) { BOOL isCurrentThread = MACH_PORT_INDEX(threads[i]) == MACH_PORT_INDEX(bsg_ksmachthread_self()); if (isCurrentThread) { backtraces[i].length = 0; // currentThreadBacktrace will be used instead @@ -94,7 +94,7 @@ @implementation BugsnagThread (Recording) NSMutableArray *objects = [NSMutableArray arrayWithCapacity:threadCount]; - for (int i = 0; i < threadCount; i++) { + for (mach_msg_type_number_t i = 0; i < threadCount; i++) { BOOL isCurrentThread = MACH_PORT_INDEX(threads[i]) == MACH_PORT_INDEX(bsg_ksmachthread_self()); struct backtrace_t *backtrace = isCurrentThread ? currentThreadBacktrace : &backtraces[i]; [objects addObject:[[BugsnagThread alloc] initWithMachThread:threads[i] @@ -104,7 +104,7 @@ @implementation BugsnagThread (Recording) index:i]]; } - for (int i = 0; i < threadCount; i++) { + for (mach_msg_type_number_t i = 0; i < threadCount; i++) { mach_port_deallocate(mach_task_self(), threads[i]); } vm_deallocate(mach_task_self(), (vm_address_t)threads, sizeof(thread_t) * threadCount); @@ -116,9 +116,9 @@ + (instancetype)currentThreadWithBacktrace:(struct backtrace_t *)backtrace { thread_t thread = mach_thread_self(); thread_t *threads = NULL; mach_msg_type_number_t threadCount = 0; - int threadIndex = 0; + mach_msg_type_number_t threadIndex = 0; if (task_threads(mach_task_self(), &threads, &threadCount) == KERN_SUCCESS) { - for (int i = 0; i < threadCount; i++) { + for (mach_msg_type_number_t i = 0; i < threadCount; i++) { if (MACH_PORT_INDEX(threads[i]) == MACH_PORT_INDEX(thread)) { threadIndex = i; } @@ -162,7 +162,7 @@ + (nullable instancetype)mainThread { index:0]; } - for (int i = 0; i < threadCount; i++) { + for (mach_msg_type_number_t i = 0; i < threadCount; i++) { mach_port_deallocate(mach_task_self(), threads[i]); } vm_deallocate(mach_task_self(), (vm_address_t)threads, sizeof(thread_t) * threadCount); @@ -172,9 +172,9 @@ + (nullable instancetype)mainThread { - (instancetype)initWithMachThread:(thread_t)machThread backtraceAddresses:(uintptr_t *)backtraceAddresses - backtraceLength:(int)backtraceLength + backtraceLength:(NSUInteger)backtraceLength errorReportingThread:(BOOL)errorReportingThread - index:(int)index { + index:(unsigned)index { char name[64] = ""; if (!bsg_ksmachgetThreadName(machThread, name, sizeof(name)) || !name[0]) { diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread.m index 253035ff4a..11d32079b7 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread.m @@ -57,11 +57,11 @@ - (instancetype)initWithId:(NSString *)id - (instancetype)initWithThread:(NSDictionary *)thread binaryImages:(NSArray *)binaryImages { if (self = [super init]) { - _errorReportingThread = [thread[@(BSG_KSCrashField_Crashed)] boolValue]; - _id = [thread[@(BSG_KSCrashField_Index)] stringValue]; + _errorReportingThread = [thread[@BSG_KSCrashField_Crashed] boolValue]; + _id = [thread[@BSG_KSCrashField_Index] stringValue]; _type = BSGThreadTypeCocoa; - _crashInfoMessage = [thread[@(BSG_KSCrashField_CrashInfoMessage)] copy]; - NSArray *backtrace = thread[@(BSG_KSCrashField_Backtrace)][@(BSG_KSCrashField_Contents)]; + _crashInfoMessage = [thread[@BSG_KSCrashField_CrashInfoMessage] copy]; + NSArray *backtrace = thread[@BSG_KSCrashField_Backtrace][@BSG_KSCrashField_Contents]; BugsnagStacktrace *frames = [[BugsnagStacktrace alloc] initWithTrace:backtrace binaryImages:binaryImages]; _stacktrace = [frames.trace copy]; } @@ -138,7 +138,7 @@ + (NSDictionary *)enhanceThreadInfo:(NSDictionary *)thread NSMutableArray *stacktrace = [NSMutableArray array]; for (NSDictionary *frame in backtrace) { - NSMutableDictionary *mutableFrame = (NSMutableDictionary *) [frame mutableCopy]; + NSMutableDictionary *mutableFrame = [frame mutableCopy]; if (seen++ >= depth) { // Mark the frame so we know where it came from if (seen == 1 && !stackOverflow) { @@ -150,10 +150,11 @@ + (NSDictionary *)enhanceThreadInfo:(NSDictionary *)thread [stacktrace addObject:mutableFrame]; } } - NSMutableDictionary *copy = [NSMutableDictionary dictionaryWithDictionary:thread]; - copy[@"backtrace"] = [NSMutableDictionary dictionaryWithDictionary:copy[@"backtrace"]]; - copy[@"backtrace"][@"contents"] = stacktrace; - return copy; + NSMutableDictionary *mutableBacktrace = [thread[@"backtrace"] mutableCopy]; + mutableBacktrace[@"contents"] = stacktrace; + NSMutableDictionary *mutableThread = [thread mutableCopy]; + mutableThread[@"backtrace"] = mutableBacktrace; + return mutableThread; } return thread; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Plugins/BugsnagPluginClient.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Plugins/BugsnagPluginClient.m index d297c49528..e145976783 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Plugins/BugsnagPluginClient.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Plugins/BugsnagPluginClient.m @@ -14,8 +14,8 @@ static NSString *const kPluginReactNative = @"BugsnagReactNativePlugin"; @interface BugsnagPluginClient () -@property NSSet> *plugins; -@property BugsnagClient *client; +@property (nonatomic) NSSet> *plugins; +@property (nonatomic) BugsnagClient *client; @end @implementation BugsnagPluginClient diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BSGFileLocations.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BSGFileLocations.m index 22da673493..68693a66d5 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BSGFileLocations.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BSGFileLocations.m @@ -42,7 +42,8 @@ static BOOL ensureDirExists(NSString *path) { rootPath = [NSString stringWithFormat:@"%@/com.bugsnag.Bugsnag/%@/%@", url.path, - [NSBundle mainBundle].bundleIdentifier, + // Processes that don't have an Info.plist have no bundleIdentifier + NSBundle.mainBundle.bundleIdentifier ?: NSProcessInfo.processInfo.processName, fsVersion]; // If we can't even create the root dir, all is lost, and no file ops can be allowed. diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BugsnagFileStore.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BugsnagFileStore.m index 599194b3a1..0909e65f5e 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BugsnagFileStore.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BugsnagFileStore.m @@ -245,9 +245,6 @@ - (NSMutableDictionary *)readFile:(NSString *)path NSMutableDictionary *fileContents = [BSG_KSJSONCodec decode:jsonData - options:BSG_KSJSONDecodeOptionIgnoreNullInArray | - BSG_KSJSONDecodeOptionIgnoreNullInObject | - BSG_KSJSONDecodeOptionKeepPartialObject error:error]; if (error != nil && *error != nil) { diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BugsnagSessionFileStore.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BugsnagSessionFileStore.m index 3ab62d019e..78714328d9 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BugsnagSessionFileStore.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Storage/BugsnagSessionFileStore.m @@ -13,7 +13,7 @@ @interface BugsnagSessionFileStore () -@property NSUInteger maxPersistedSessions; +@property (nonatomic) NSUInteger maxPersistedSessions; @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagBreadcrumb.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagBreadcrumb.h index 61a6c6f678..cae86eaeb0 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagBreadcrumb.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagBreadcrumb.h @@ -102,23 +102,23 @@ typedef NS_OPTIONS(NSUInteger, BSGEnabledBreadcrumbType) { /** * The date when the breadcrumb was left */ -@property(readonly, nullable) NSDate *timestamp; +@property (readonly, nullable, nonatomic) NSDate *timestamp; /** * The type of breadcrumb */ -@property(readwrite) BSGBreadcrumbType type; +@property (readwrite, nonatomic) BSGBreadcrumbType type; /** * The description of the breadcrumb */ -@property(readwrite, copy, nonnull) NSString *message; +@property (readwrite, copy, nonnull, nonatomic) NSString *message; /** * Diagnostic data relating to the breadcrumb. * * The dictionary should be a valid JSON object. */ -@property(readwrite, copy, nonnull) NSDictionary *metadata; +@property (readwrite, copy, nonnull, nonatomic) NSDictionary *metadata; @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagConfiguration.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagConfiguration.h index 8448efe667..d81bf2e585 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagConfiguration.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagConfiguration.h @@ -185,7 +185,7 @@ typedef BOOL (^BugsnagOnSessionBlock)(BugsnagSession *_Nonnull session); /** * The URL session used to send requests to Bugsnag. */ -@property(readwrite, strong, nonnull) NSURLSession *session; +@property (readwrite, strong, nonnull, nonatomic) NSURLSession *session; /** * Controls whether Bugsnag should capture and serialize the state of all threads at the time @@ -195,18 +195,17 @@ typedef BOOL (^BugsnagOnSessionBlock)(BugsnagSession *_Nonnull session); * BSGThreadSendPolicyNever to disable or BSGThreadSendPolicyUnhandledOnly * to only do so for unhandled errors. */ -@property BSGThreadSendPolicy sendThreads; +@property (nonatomic) BSGThreadSendPolicy sendThreads; /** * Optional handler invoked when an error or crash occurs */ -@property void (*_Nullable onCrashHandler) - (const BSG_KSCrashReportWriter *_Nonnull writer); +@property (nullable, nonatomic) void (* onCrashHandler)(const BSG_KSCrashReportWriter *); /** * YES if uncaught exceptions and other crashes should be reported automatically */ -@property BOOL autoDetectErrors; +@property (nonatomic) BOOL autoDetectErrors; /** * The minimum number of milliseconds of main thread unresponsiveness that will trigger the @@ -225,7 +224,7 @@ typedef BOOL (^BugsnagOnSessionBlock)(BugsnagSession *_Nonnull session); * If this value is updated after +[Bugsnag start] is called, only subsequent automatic sessions * will be captured. */ -@property BOOL autoTrackSessions; +@property (nonatomic) BOOL autoTrackSessions; /** * The amount of time (in milliseconds) after starting Bugsnag that should be considered part of @@ -254,7 +253,7 @@ typedef BOOL (^BugsnagOnSessionBlock)(BugsnagSession *_Nonnull session); /** * The types of breadcrumbs which will be captured. By default, this is all types. */ -@property BSGEnabledBreadcrumbType enabledBreadcrumbTypes; +@property (nonatomic) BSGEnabledBreadcrumbType enabledBreadcrumbTypes; /** * The app's bundleVersion, set from the CFBundleVersion. Equivalent to `versionCode` on Android. @@ -285,13 +284,13 @@ typedef BOOL (^BugsnagOnSessionBlock)(BugsnagSession *_Nonnull session); * * By default, 25 breadcrumbs are stored: this can be amended up to a maximum of 100. */ -@property NSUInteger maxBreadcrumbs; +@property (nonatomic) NSUInteger maxBreadcrumbs; /** * Whether User information should be persisted to disk between application runs. * Defaults to True. */ -@property BOOL persistUser; +@property (nonatomic) BOOL persistUser; // ----------------------------------------------------------------------------- // MARK: - Methods diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagErrorTypes.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagErrorTypes.h index 8d9a767dd4..a3c0df0abf 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagErrorTypes.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagErrorTypes.h @@ -18,48 +18,48 @@ * * This flag is true by default. */ -@property BOOL appHangs; +@property (nonatomic) BOOL appHangs; /** * Determines whether Out of Memory events should be reported to bugsnag. * * This flag is true by default. */ -@property BOOL ooms; +@property (nonatomic) BOOL ooms; /** * Determines whether NSExceptions should be reported to bugsnag. * * This flag is true by default. */ -@property BOOL unhandledExceptions; +@property (nonatomic) BOOL unhandledExceptions; /** * Determines whether signals should be reported to bugsnag. * * This flag is true by default. */ -@property BOOL signals; +@property (nonatomic) BOOL signals; /** * Determines whether C errors should be reported to bugsnag. * * This flag is true by default. */ -@property BOOL cppExceptions; +@property (nonatomic) BOOL cppExceptions; /** * Determines whether Mach Exceptions should be reported to bugsnag. * * This flag is true by default. */ -@property BOOL machExceptions; +@property (nonatomic) BOOL machExceptions; /** * Sets whether Bugsnag should automatically capture and report unhandled promise rejections. * This only applies to React Native apps. * By default, this value is true. */ -@property BOOL unhandledRejections; +@property (nonatomic) BOOL unhandledRejections; @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagEvent.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagEvent.h index 6879e38139..e5bde39320 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagEvent.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagEvent.h @@ -43,56 +43,56 @@ typedef NS_ENUM(NSUInteger, BSGSeverity) { * A loose representation of what was happening in the application at the time * of the event */ -@property(readwrite, copy, nullable) NSString *context; +@property (readwrite, copy, nullable, nonatomic) NSString *context; /** * The severity of the error generating the report */ -@property(readwrite) BSGSeverity severity; +@property (readwrite, nonatomic) BSGSeverity severity; /** * Information extracted from the error that caused the event. The list contains * at least one error that represents the root cause, with subsequent elements populated * from the cause. */ -@property(readwrite, copy, nonnull) NSArray *errors; +@property (readwrite, copy, nonnull, nonatomic) NSArray *errors; /** * Customized hash for grouping this report with other errors */ -@property(readwrite, copy, nullable) NSString *groupingHash; +@property (readwrite, copy, nullable, nonatomic) NSString *groupingHash; /** * Breadcrumbs from user events leading up to the error */ -@property(readwrite, copy, nonnull) NSArray *breadcrumbs; +@property (readwrite, copy, nonnull, nonatomic) NSArray *breadcrumbs; /** * A per-event override for the apiKey. * - The default value of nil results in the BugsnagConfiguration apiKey being used. * - Writes are not persisted to BugsnagConfiguration. */ -@property(readwrite, copy, nullable, nonatomic) NSString *apiKey; +@property (readwrite, copy, nullable, nonatomic) NSString *apiKey; /** * Device information such as OS name and version */ -@property(readonly, nonnull) BugsnagDeviceWithState *device; +@property (readonly, nonnull, nonatomic) BugsnagDeviceWithState *device; /** * App information such as the name, version, and bundle ID */ -@property(readonly, nonnull) BugsnagAppWithState *app; +@property (readonly, nonnull, nonatomic) BugsnagAppWithState *app; /** * Whether the event was a crash (i.e. unhandled) or handled error in which the system * continued running. */ -@property(readwrite) BOOL unhandled; +@property (readwrite, nonatomic) BOOL unhandled; /** * Thread traces for the error that occurred, if collection was enabled. */ -@property(readwrite, copy, nonnull) NSArray *threads; +@property (readwrite, copy, nonnull, nonatomic) NSArray *threads; /** * The original object that caused the error in your application. This value will only be populated for @@ -102,7 +102,7 @@ typedef NS_ENUM(NSUInteger, BSGSeverity) { * Bugsnag dashboard. Use event.errors to access and amend the representation of * the error that will be sent. */ -@property(strong, nullable, nonatomic) id originalError; +@property (strong, nullable, nonatomic) id originalError; // ============================================================================= @@ -112,7 +112,7 @@ typedef NS_ENUM(NSUInteger, BSGSeverity) { /** * The current user */ -@property(readonly, nonatomic, nonnull) BugsnagUser *user; +@property (readonly, nonnull, nonatomic) BugsnagUser *user; /** * Set user metadata diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagStackframe.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagStackframe.h index 813755445c..882396b432 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagStackframe.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagStackframe.h @@ -57,12 +57,12 @@ FOUNDATION_EXPORT BugsnagStackframeType const BugsnagStackframeTypeCocoa; /** * Whether the frame was within the program counter */ -@property BOOL isPc; +@property (nonatomic) BOOL isPc; /** * Whether the frame was within the link register */ -@property BOOL isLr; +@property (nonatomic) BOOL isLr; /** * The type of the stack frame, if it differs from that of the containing error or event. diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagThread.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagThread.h index 44716fc298..bfaac04048 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagThread.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagThread.h @@ -44,6 +44,6 @@ typedef NS_OPTIONS(NSUInteger, BSGThreadType) { * Determines the type of thread based on the originating platform * (intended for internal use only) */ -@property BSGThreadType type; +@property (nonatomic) BSGThreadType type; @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md b/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md index 0b9292548a..6054134c64 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md @@ -1,6 +1,19 @@ Changelog ========= +## 6.9.0 (2021-04-21) + +### Enhancements + +* App hangs that occur while the app is in the background will no longer be reported. + [#1075](https://github.com/bugsnag/bugsnag-cocoa/pull/1075) + +* Add `binaryArch` and `runningOnRosetta` to the `app` metadata tab. + [#1073](https://github.com/bugsnag/bugsnag-cocoa/pull/1073) + +* Bugsnag can now be used without AppKit, allowing use in daemons and other processes running in non-UI sessions. + [#1072](https://github.com/bugsnag/bugsnag-cocoa/pull/1072) + ## 6.8.4 (2021-04-14) ### Enhancements diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist b/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist index 3052529a45..84a1eee484 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 6.8.4 + 6.9.0 CFBundleVersion 1 diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION b/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION index 9ffc8cfb6c..97f5781528 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION @@ -1 +1 @@ -6.8.4 +6.9.0