From 5743c5845ffd87765e535c96fe941f7024eca588 Mon Sep 17 00:00:00 2001 From: Nick Dowell Date: Mon, 12 Sep 2022 08:47:45 +0100 Subject: [PATCH 1/2] Use __attribute__((objc_direct_members)) --- Bugsnag.xcodeproj/project.pbxproj | 32 +++++++++++++++++ .../Breadcrumbs/BSGNotificationBreadcrumbs.h | 3 ++ .../Breadcrumbs/BSGNotificationBreadcrumbs.m | 20 +++++++++++ Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.h | 3 ++ Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.m | 1 + Bugsnag/Bugsnag+Private.h | 5 +-- Bugsnag/Bugsnag.m | 1 + Bugsnag/BugsnagSessionTracker.h | 35 +++++++++++-------- Bugsnag/BugsnagSessionTracker.m | 2 ++ Bugsnag/BugsnagSystemState.h | 2 ++ Bugsnag/BugsnagSystemState.m | 2 ++ Bugsnag/Client/BugsnagClient+Private.h | 2 ++ Bugsnag/Client/BugsnagClient.m | 10 ++++++ .../BugsnagConfiguration+Private.h | 5 +++ Bugsnag/Configuration/BugsnagConfiguration.m | 1 + Bugsnag/Delivery/BSGConnectivity.h | 1 + .../Delivery/BSGEventUploadFileOperation.h | 3 ++ .../Delivery/BSGEventUploadFileOperation.m | 1 + .../BSGEventUploadKSCrashReportOperation.h | 3 ++ .../BSGEventUploadKSCrashReportOperation.m | 1 + .../Delivery/BSGEventUploadObjectOperation.h | 3 ++ .../Delivery/BSGEventUploadObjectOperation.m | 1 + Bugsnag/Delivery/BSGEventUploader.h | 3 ++ Bugsnag/Delivery/BSGEventUploader.m | 1 + Bugsnag/Delivery/BSGSessionUploader.h | 3 ++ Bugsnag/Delivery/BSGSessionUploader.m | 2 ++ Bugsnag/Helpers/BSGAppHangDetector.h | 1 + Bugsnag/Helpers/BSGAppHangDetector.m | 21 +++++++---- Bugsnag/Helpers/BSGDefines.h | 11 ++++++ Bugsnag/Helpers/BSGInternalErrorReporter.h | 29 ++++++++------- Bugsnag/Helpers/BSGInternalErrorReporter.m | 2 ++ Bugsnag/Helpers/BSG_RFC3339DateTool.h | 2 ++ .../Source/KSCrash/Recording/BSG_KSCrash.h | 2 ++ .../KSCrash/Recording/BSG_KSCrashDoctor.h | 3 ++ .../KSCrash/Recording/BSG_KSCrashDoctor.m | 1 + .../KSCrash/Recording/BSG_KSSystemInfo.h | 4 ++- .../KSCrash/Recording/BSG_KSSystemInfo.m | 1 + Bugsnag/Metadata/BugsnagMetadata+Private.h | 3 ++ Bugsnag/Metadata/BugsnagMetadata.m | 2 ++ Bugsnag/Payload/BugsnagBreadcrumb+Private.h | 4 +-- Bugsnag/Payload/BugsnagBreadcrumb.m | 1 + Bugsnag/Payload/BugsnagError+Private.h | 2 ++ Bugsnag/Payload/BugsnagError.m | 1 + Bugsnag/Payload/BugsnagEvent+Private.h | 2 ++ Bugsnag/Payload/BugsnagEvent.m | 1 + Bugsnag/Payload/BugsnagHandledState.m | 2 ++ Bugsnag/Payload/BugsnagSession+Private.h | 1 + Bugsnag/Payload/BugsnagSession.m | 3 +- Bugsnag/Payload/BugsnagStackframe+Private.h | 2 ++ Bugsnag/Payload/BugsnagStackframe.m | 1 + Bugsnag/Payload/BugsnagStacktrace.h | 3 ++ Bugsnag/Payload/BugsnagStacktrace.m | 1 + Bugsnag/Payload/BugsnagThread+Private.h | 1 + Bugsnag/Payload/BugsnagThread.m | 1 + Bugsnag/Payload/BugsnagUser+Private.h | 2 ++ Bugsnag/Payload/BugsnagUser.m | 1 + Bugsnag/Storage/BSGFileLocations.h | 3 ++ Bugsnag/Storage/BSGFileLocations.m | 1 + Bugsnag/Storage/BSGStorageMigratorV0V1.h | 3 ++ Bugsnag/Storage/BSGStorageMigratorV0V1.m | 1 + 60 files changed, 226 insertions(+), 39 deletions(-) diff --git a/Bugsnag.xcodeproj/project.pbxproj b/Bugsnag.xcodeproj/project.pbxproj index 2318dcc95..30ee4cd76 100644 --- a/Bugsnag.xcodeproj/project.pbxproj +++ b/Bugsnag.xcodeproj/project.pbxproj @@ -3984,6 +3984,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "BSG_OBJC_DIRECT_MEMBERS=''", + ); INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -4024,6 +4028,10 @@ buildSettings = { CODE_SIGN_STYLE = Automatic; DEVELOPMENT_TEAM = 372ZUL2ZB7; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "BSG_OBJC_DIRECT_MEMBERS=''", + ); INFOPLIST_FILE = Tests/BugsnagTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -4070,6 +4078,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "BSG_OBJC_DIRECT_MEMBERS=''", + ); INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -4110,6 +4122,10 @@ buildSettings = { CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "BSG_OBJC_DIRECT_MEMBERS=''", + ); INFOPLIST_FILE = Tests/BugsnagTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -4152,6 +4168,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "BSG_OBJC_DIRECT_MEMBERS=''", + ); INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -4191,6 +4211,10 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "BSG_OBJC_DIRECT_MEMBERS=''", + ); INFOPLIST_FILE = Tests/BugsnagTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", @@ -4315,6 +4339,10 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "BSG_OBJC_DIRECT_MEMBERS=''", + ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -4426,6 +4454,10 @@ CODE_SIGN_STYLE = Automatic; CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_TEAM = 372ZUL2ZB7; + GCC_PREPROCESSOR_DEFINITIONS = ( + "$(inherited)", + "BSG_OBJC_DIRECT_MEMBERS=''", + ); GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; diff --git a/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.h b/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.h index 94f30f72a..a26698172 100644 --- a/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.h +++ b/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.h @@ -8,12 +8,15 @@ #import +#import "BSGDefines.h" + @class BugsnagConfiguration; NS_ASSUME_NONNULL_BEGIN static NSString * const BSGNotificationBreadcrumbsMessageAppWillTerminate = @"App Will Terminate"; +BSG_OBJC_DIRECT_MEMBERS @interface BSGNotificationBreadcrumbs : NSObject #pragma mark Initializers diff --git a/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.m b/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.m index 98bbeb44a..b210134c9 100644 --- a/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.m +++ b/Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.m @@ -19,13 +19,33 @@ #define BSG_HAVE_TABLE_VIEW (TARGET_OS_OSX || TARGET_OS_IOS || TARGET_OS_TV) #define BSG_HAVE_TEXT_CONTROL (TARGET_OS_OSX || TARGET_OS_IOS ) +BSG_OBJC_DIRECT_MEMBERS @interface BSGNotificationBreadcrumbs () @property (nonatomic) NSDictionary *notificationNameMap; @end +@interface BSGNotificationBreadcrumbs (/* not objc_direct */) +- (void)addBreadcrumbForNotification:(NSNotification *)notification; + +- (void)addBreadcrumbForControlNotification:(NSNotification *)notification; + +- (void)addBreadcrumbForMenuItemNotification:(NSNotification *)notification; + +- (void)addBreadcrumbForTableViewNotification:(NSNotification *)notification; + +#if TARGET_OS_IOS +- (void)orientationDidChange:(NSNotification *)notification; +#endif + +- (void)thermalStateDidChange:(NSNotification *)notification API_AVAILABLE(ios(11.0), tvos(11.0)); + +@end + + +BSG_OBJC_DIRECT_MEMBERS @implementation BSGNotificationBreadcrumbs - (instancetype)initWithConfiguration:(BugsnagConfiguration *)configuration diff --git a/Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.h b/Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.h index 1395bad52..e50b5ba7c 100644 --- a/Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.h +++ b/Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.h @@ -8,12 +8,15 @@ #import +#import "BSGDefines.h" + @class BugsnagBreadcrumb; @class BugsnagConfiguration; typedef struct BSG_KSCrashReportWriter BSG_KSCrashReportWriter; NS_ASSUME_NONNULL_BEGIN +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagBreadcrumbs : NSObject - (instancetype)initWithConfiguration:(BugsnagConfiguration *)config; diff --git a/Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.m b/Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.m index 4591858ea..15e94385b 100644 --- a/Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.m +++ b/Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.m @@ -47,6 +47,7 @@ @interface BugsnagBreadcrumbs () #pragma mark - +BSG_OBJC_DIRECT_MEMBERS @implementation BugsnagBreadcrumbs - (instancetype)initWithConfiguration:(BugsnagConfiguration *)config { diff --git a/Bugsnag/Bugsnag+Private.h b/Bugsnag/Bugsnag+Private.h index 16618eb98..92df01047 100644 --- a/Bugsnag/Bugsnag+Private.h +++ b/Bugsnag/Bugsnag+Private.h @@ -8,16 +8,17 @@ #import +#import "BSGDefines.h" + NS_ASSUME_NONNULL_BEGIN +BSG_OBJC_DIRECT_MEMBERS @interface Bugsnag () #pragma mark Methods + (void)purge; -+ (void)removeOnBreadcrumbBlock:(BugsnagOnBreadcrumbBlock)block; - @end NS_ASSUME_NONNULL_END diff --git a/Bugsnag/Bugsnag.m b/Bugsnag/Bugsnag.m index eaf98653f..fbe714dc3 100644 --- a/Bugsnag/Bugsnag.m +++ b/Bugsnag/Bugsnag.m @@ -35,6 +35,7 @@ static BugsnagClient *bsg_g_bugsnag_client = NULL; +BSG_OBJC_DIRECT_MEMBERS @implementation Bugsnag + (BugsnagClient *_Nonnull)start { diff --git a/Bugsnag/BugsnagSessionTracker.h b/Bugsnag/BugsnagSessionTracker.h index 30ecab78f..a03c7fe54 100644 --- a/Bugsnag/BugsnagSessionTracker.h +++ b/Bugsnag/BugsnagSessionTracker.h @@ -15,6 +15,7 @@ NS_ASSUME_NONNULL_BEGIN +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagSessionTracker : NSObject /** @@ -41,21 +42,6 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)startNewSessionIfAutoCaptureEnabled; -/** - Handle the app foregrounding event. If more than 30s has elapsed since being - sent to the background, records a new session if session auto-capture is - enabled. - Must be called from the main thread. - */ -- (void)handleAppForegroundEvent; - -/** - Handle the app backgrounding event. Tracks time between foreground and - background to determine when to automatically record a session. - Must be called from the main thread. - */ -- (void)handleAppBackgroundEvent; - /** Handle some variation of Bugsnag.notify() being called. Increments the number of handled or unhandled errors recorded for the current session, if @@ -79,4 +65,23 @@ NS_ASSUME_NONNULL_BEGIN @end +@interface BugsnagSessionTracker (/* not objc_direct */) + +/** + Handle the app foregrounding event. If more than 30s has elapsed since being + sent to the background, records a new session if session auto-capture is + enabled. + Must be called from the main thread. + */ +- (void)handleAppForegroundEvent; + +/** + Handle the app backgrounding event. Tracks time between foreground and + background to determine when to automatically record a session. + Must be called from the main thread. + */ +- (void)handleAppBackgroundEvent; + +@end + NS_ASSUME_NONNULL_END diff --git a/Bugsnag/BugsnagSessionTracker.m b/Bugsnag/BugsnagSessionTracker.m index b66509544..9162fb399 100644 --- a/Bugsnag/BugsnagSessionTracker.m +++ b/Bugsnag/BugsnagSessionTracker.m @@ -27,6 +27,7 @@ */ static NSTimeInterval const BSGNewSessionBackgroundDuration = 30; +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagSessionTracker () @property (strong, nonatomic) BugsnagConfiguration *config; @property (weak, nonatomic) BugsnagClient *client; @@ -34,6 +35,7 @@ @interface BugsnagSessionTracker () @property (nonatomic) NSMutableDictionary *extraRuntimeInfo; @end +BSG_OBJC_DIRECT_MEMBERS @implementation BugsnagSessionTracker - (instancetype)initWithConfig:(BugsnagConfiguration *)config client:(BugsnagClient *)client { diff --git a/Bugsnag/BugsnagSystemState.h b/Bugsnag/BugsnagSystemState.h index 8ee336f4b..931c80959 100644 --- a/Bugsnag/BugsnagSystemState.h +++ b/Bugsnag/BugsnagSystemState.h @@ -10,6 +10,7 @@ #import +#import "BSGDefines.h" #import "BSGKeys.h" #define SYSTEMSTATE_KEY_APP @"app" @@ -19,6 +20,7 @@ NS_ASSUME_NONNULL_BEGIN +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagSystemState : NSObject @property(readonly,nonatomic) NSDictionary *lastLaunchState; diff --git a/Bugsnag/BugsnagSystemState.m b/Bugsnag/BugsnagSystemState.m index 5902c676d..0171204aa 100644 --- a/Bugsnag/BugsnagSystemState.m +++ b/Bugsnag/BugsnagSystemState.m @@ -106,6 +106,7 @@ id blankIfNil(id value) { return dictionary; } +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagSystemState () @property(readwrite,atomic) NSDictionary *currentLaunchState; @@ -114,6 +115,7 @@ @interface BugsnagSystemState () @end +BSG_OBJC_DIRECT_MEMBERS @implementation BugsnagSystemState - (instancetype)initWithConfiguration:(BugsnagConfiguration *)config { diff --git a/Bugsnag/Client/BugsnagClient+Private.h b/Bugsnag/Client/BugsnagClient+Private.h index 03cf358d0..ef5e1827c 100644 --- a/Bugsnag/Client/BugsnagClient+Private.h +++ b/Bugsnag/Client/BugsnagClient+Private.h @@ -6,6 +6,7 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // +#import "BSGDefines.h" #import "BugsnagInternals.h" @class BSGAppHangDetector; @@ -21,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagClient () #pragma mark Properties diff --git a/Bugsnag/Client/BugsnagClient.m b/Bugsnag/Client/BugsnagClient.m index d7a3f4516..bca1c4ce3 100644 --- a/Bugsnag/Client/BugsnagClient.m +++ b/Bugsnag/Client/BugsnagClient.m @@ -149,6 +149,7 @@ static void BSSerializeDataCrashHandler(const BSG_KSCrashReportWriter *writer) { // MARK: - +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagClient () @property (nonatomic) BSGNotificationBreadcrumbs *notificationBreadcrumbs; @@ -163,6 +164,14 @@ @interface BugsnagClient () @end @@ -174,6 +183,7 @@ @interface BugsnagClient () __attribute__((annotate("oclint:suppress[long class]"))) __attribute__((annotate("oclint:suppress[too many methods]"))) #endif +BSG_OBJC_DIRECT_MEMBERS @implementation BugsnagClient - (instancetype)initWithConfiguration:(BugsnagConfiguration *)configuration { diff --git a/Bugsnag/Configuration/BugsnagConfiguration+Private.h b/Bugsnag/Configuration/BugsnagConfiguration+Private.h index 5918f9aa3..a5cc826fb 100644 --- a/Bugsnag/Configuration/BugsnagConfiguration+Private.h +++ b/Bugsnag/Configuration/BugsnagConfiguration+Private.h @@ -6,12 +6,14 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // +#import "BSGDefines.h" #import "BugsnagInternals.h" @class BugsnagNotifier; NS_ASSUME_NONNULL_BEGIN +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagConfiguration () #pragma mark Initializers @@ -50,4 +52,7 @@ NS_ASSUME_NONNULL_BEGIN @end +@interface BugsnagConfiguration (/* not objc_direct */) +@end + NS_ASSUME_NONNULL_END diff --git a/Bugsnag/Configuration/BugsnagConfiguration.m b/Bugsnag/Configuration/BugsnagConfiguration.m index d23e1c116..1d2e5ed30 100644 --- a/Bugsnag/Configuration/BugsnagConfiguration.m +++ b/Bugsnag/Configuration/BugsnagConfiguration.m @@ -45,6 +45,7 @@ // MARK: - BugsnagConfiguration // ============================================================================= +BSG_OBJC_DIRECT_MEMBERS @implementation BugsnagConfiguration + (instancetype _Nonnull)loadConfig { diff --git a/Bugsnag/Delivery/BSGConnectivity.h b/Bugsnag/Delivery/BSGConnectivity.h index 2621959ea..d90303275 100644 --- a/Bugsnag/Delivery/BSGConnectivity.h +++ b/Bugsnag/Delivery/BSGConnectivity.h @@ -45,6 +45,7 @@ typedef void (^BSGConnectivityChangeBlock)(BOOL connected, NSString *typeDescrip * Monitors network connectivity using SCNetworkReachability callbacks, * providing a customizable callback block invoked when connectivity changes. */ +BSG_OBJC_DIRECT_MEMBERS @interface BSGConnectivity : NSObject /** diff --git a/Bugsnag/Delivery/BSGEventUploadFileOperation.h b/Bugsnag/Delivery/BSGEventUploadFileOperation.h index e48842b7b..ec13f4b94 100644 --- a/Bugsnag/Delivery/BSGEventUploadFileOperation.h +++ b/Bugsnag/Delivery/BSGEventUploadFileOperation.h @@ -8,11 +8,14 @@ #import "BSGEventUploadOperation.h" +#import "BSGDefines.h" + NS_ASSUME_NONNULL_BEGIN /** * A concrete operation class for uploading an event that is stored on disk. */ +BSG_OBJC_DIRECT_MEMBERS @interface BSGEventUploadFileOperation : BSGEventUploadOperation - (instancetype)initWithFile:(NSString *)file delegate:(id)delegate; diff --git a/Bugsnag/Delivery/BSGEventUploadFileOperation.m b/Bugsnag/Delivery/BSGEventUploadFileOperation.m index f19414842..55ff2dd76 100644 --- a/Bugsnag/Delivery/BSGEventUploadFileOperation.m +++ b/Bugsnag/Delivery/BSGEventUploadFileOperation.m @@ -16,6 +16,7 @@ #import "BugsnagLogger.h" +BSG_OBJC_DIRECT_MEMBERS @implementation BSGEventUploadFileOperation - (instancetype)initWithFile:(NSString *)file delegate:(id)delegate { diff --git a/Bugsnag/Delivery/BSGEventUploadKSCrashReportOperation.h b/Bugsnag/Delivery/BSGEventUploadKSCrashReportOperation.h index c83382adf..3b5f69c12 100644 --- a/Bugsnag/Delivery/BSGEventUploadKSCrashReportOperation.h +++ b/Bugsnag/Delivery/BSGEventUploadKSCrashReportOperation.h @@ -8,11 +8,14 @@ #import "BSGEventUploadFileOperation.h" +#import "BSGDefines.h" + NS_ASSUME_NONNULL_BEGIN /** * A concrete operation class for reading a KSCrashReport from disk, converting it into a BugsnagEvent, and uploading. */ +BSG_OBJC_DIRECT_MEMBERS @interface BSGEventUploadKSCrashReportOperation : BSGEventUploadFileOperation @end diff --git a/Bugsnag/Delivery/BSGEventUploadKSCrashReportOperation.m b/Bugsnag/Delivery/BSGEventUploadKSCrashReportOperation.m index 43863aeb8..ca3d5302d 100644 --- a/Bugsnag/Delivery/BSGEventUploadKSCrashReportOperation.m +++ b/Bugsnag/Delivery/BSGEventUploadKSCrashReportOperation.m @@ -51,6 +51,7 @@ } +BSG_OBJC_DIRECT_MEMBERS @implementation BSGEventUploadKSCrashReportOperation - (BugsnagEvent *)loadEventAndReturnError:(NSError * __autoreleasing *)errorPtr { diff --git a/Bugsnag/Delivery/BSGEventUploadObjectOperation.h b/Bugsnag/Delivery/BSGEventUploadObjectOperation.h index 9729baaaa..b852e45d9 100644 --- a/Bugsnag/Delivery/BSGEventUploadObjectOperation.h +++ b/Bugsnag/Delivery/BSGEventUploadObjectOperation.h @@ -8,6 +8,8 @@ #import "BSGEventUploadOperation.h" +#import "BSGDefines.h" + NS_ASSUME_NONNULL_BEGIN /** @@ -15,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN * * If the upload needs to be retried, the event will be persisted to disk. */ +BSG_OBJC_DIRECT_MEMBERS @interface BSGEventUploadObjectOperation : BSGEventUploadOperation - (instancetype)initWithEvent:(BugsnagEvent *)event delegate:(id)delegate; diff --git a/Bugsnag/Delivery/BSGEventUploadObjectOperation.m b/Bugsnag/Delivery/BSGEventUploadObjectOperation.m index 05a691779..ea4f754fd 100644 --- a/Bugsnag/Delivery/BSGEventUploadObjectOperation.m +++ b/Bugsnag/Delivery/BSGEventUploadObjectOperation.m @@ -12,6 +12,7 @@ #import "BugsnagInternals.h" #import "BugsnagLogger.h" +BSG_OBJC_DIRECT_MEMBERS @implementation BSGEventUploadObjectOperation - (instancetype)initWithEvent:(BugsnagEvent *)event delegate:(id)delegate { diff --git a/Bugsnag/Delivery/BSGEventUploader.h b/Bugsnag/Delivery/BSGEventUploader.h index f41eb6703..bb5aa36a8 100644 --- a/Bugsnag/Delivery/BSGEventUploader.h +++ b/Bugsnag/Delivery/BSGEventUploader.h @@ -8,6 +8,8 @@ #import +#import "BSGDefines.h" + @class BugsnagApiClient; @class BugsnagConfiguration; @class BugsnagEvent; @@ -15,6 +17,7 @@ NS_ASSUME_NONNULL_BEGIN +BSG_OBJC_DIRECT_MEMBERS @interface BSGEventUploader : NSObject - (instancetype)initWithConfiguration:(BugsnagConfiguration *)configuration notifier:(BugsnagNotifier *)notifier; diff --git a/Bugsnag/Delivery/BSGEventUploader.m b/Bugsnag/Delivery/BSGEventUploader.m index 7db62aaa6..ff14f9914 100644 --- a/Bugsnag/Delivery/BSGEventUploader.m +++ b/Bugsnag/Delivery/BSGEventUploader.m @@ -39,6 +39,7 @@ @interface BSGEventUploader () // MARK: - +BSG_OBJC_DIRECT_MEMBERS @implementation BSGEventUploader @synthesize configuration = _configuration; diff --git a/Bugsnag/Delivery/BSGSessionUploader.h b/Bugsnag/Delivery/BSGSessionUploader.h index 4161d9014..dd914e6d4 100644 --- a/Bugsnag/Delivery/BSGSessionUploader.h +++ b/Bugsnag/Delivery/BSGSessionUploader.h @@ -7,12 +7,15 @@ #import +#import "BSGDefines.h" + @class BugsnagConfiguration; @class BugsnagNotifier; @class BugsnagSession; NS_ASSUME_NONNULL_BEGIN +BSG_OBJC_DIRECT_MEMBERS @interface BSGSessionUploader : NSObject - (instancetype)initWithConfig:(BugsnagConfiguration *)configuration notifier:(BugsnagNotifier *)notifier; diff --git a/Bugsnag/Delivery/BSGSessionUploader.m b/Bugsnag/Delivery/BSGSessionUploader.m index 6af243593..1958530e0 100644 --- a/Bugsnag/Delivery/BSGSessionUploader.m +++ b/Bugsnag/Delivery/BSGSessionUploader.m @@ -28,12 +28,14 @@ static NSArray * SortedFiles(NSFileManager *fileManager, NSMutableDictionary **creationDates); +BSG_OBJC_DIRECT_MEMBERS @interface BSGSessionUploader () @property (nonatomic) NSMutableSet *activeIds; @property(nonatomic) BugsnagConfiguration *config; @end +BSG_OBJC_DIRECT_MEMBERS @implementation BSGSessionUploader - (instancetype)initWithConfig:(BugsnagConfiguration *)config notifier:(BugsnagNotifier *)notifier { diff --git a/Bugsnag/Helpers/BSGAppHangDetector.h b/Bugsnag/Helpers/BSGAppHangDetector.h index 592c4a446..42d8f711a 100644 --- a/Bugsnag/Helpers/BSGAppHangDetector.h +++ b/Bugsnag/Helpers/BSGAppHangDetector.h @@ -21,6 +21,7 @@ NS_ASSUME_NONNULL_BEGIN @protocol BSGAppHangDetectorDelegate; +BSG_OBJC_DIRECT_MEMBERS @interface BSGAppHangDetector : NSObject - (void)startWithDelegate:(id)delegate; diff --git a/Bugsnag/Helpers/BSGAppHangDetector.m b/Bugsnag/Helpers/BSGAppHangDetector.m index 4dc0842e1..57448fbe3 100644 --- a/Bugsnag/Helpers/BSGAppHangDetector.m +++ b/Bugsnag/Helpers/BSGAppHangDetector.m @@ -20,6 +20,8 @@ #import "BugsnagLogger.h" #import "BugsnagThread+Private.h" + +BSG_OBJC_DIRECT_MEMBERS @interface BSGAppHangDetector () @property (weak, nonatomic) id delegate; @@ -27,11 +29,14 @@ @interface BSGAppHangDetector () @property (atomic) dispatch_time_t processingDeadline; @property (nonatomic) dispatch_semaphore_t processingStarted; @property (nonatomic) dispatch_semaphore_t processingFinished; -@property (weak, nonatomic) NSThread *thread; +@property (nonatomic) BOOL shouldStop; @end +static void * DetectAppHangs(void *object); + +BSG_OBJC_DIRECT_MEMBERS @implementation BSGAppHangDetector - (void)startWithDelegate:(id)delegate { @@ -109,15 +114,14 @@ - (void)startWithDelegate:(id)delegate { CFRunLoopAddObserver(CFRunLoopGetMain(), self.observer, kCFRunLoopCommonModes); - [NSThread detachNewThreadSelector:@selector(detectAppHangs) toTarget:self withObject:nil]; + pthread_t thread; + pthread_create(&thread, NULL, DetectAppHangs, (__bridge void *)(self)); } - (void)detectAppHangs { NSThread.currentThread.name = @"com.bugsnag.app-hang-detector"; - self.thread = NSThread.currentThread; - - while (!NSThread.currentThread.isCancelled) { + while (!self.shouldStop) { if (dispatch_semaphore_wait(self.processingStarted, DISPATCH_TIME_FOREVER) != 0) { bsg_log_err(@"BSGAppHangDetector: dispatch_semaphore_wait failed unexpectedly"); return; @@ -194,7 +198,7 @@ - (void)appHangEnded { } - (void)stop { - [self.thread cancel]; + self.shouldStop = YES; self.processingDeadline = DISPATCH_TIME_FOREVER; dispatch_semaphore_signal(self.processingStarted); dispatch_semaphore_signal(self.processingFinished); @@ -206,4 +210,9 @@ - (void)stop { @end +static void * DetectAppHangs(void *object) { + [(__bridge BSGAppHangDetector *)object detectAppHangs]; + return NULL; +} + #endif diff --git a/Bugsnag/Helpers/BSGDefines.h b/Bugsnag/Helpers/BSGDefines.h index e5b9f7114..6237f9fd2 100644 --- a/Bugsnag/Helpers/BSGDefines.h +++ b/Bugsnag/Helpers/BSGDefines.h @@ -29,6 +29,17 @@ // Capabilities dependent upon previously defined capabilities #define BSG_HAVE_APP_HANG_DETECTION (BSG_HAVE_MACH_THREADS) +// Causes methods to have no associated Objective-C metadata and use C function calling convention. +// See https://reviews.llvm.org/D69991 +// Overridden when building for unit testing to make private interfaces accessible. +#ifndef BSG_OBJC_DIRECT_MEMBERS +#if __has_attribute(objc_direct_members) +#define BSG_OBJC_DIRECT_MEMBERS __attribute__((objc_direct_members)) +#else +#define BSG_OBJC_DIRECT_MEMBERS +#endif +#endif + // Reference: http://iphonedevwiki.net/index.php/CoreFoundation.framework #define kCFCoreFoundationVersionNumber_iOS_12_0 1556.00 diff --git a/Bugsnag/Helpers/BSGInternalErrorReporter.h b/Bugsnag/Helpers/BSGInternalErrorReporter.h index f93e3373a..9613c31f8 100644 --- a/Bugsnag/Helpers/BSGInternalErrorReporter.h +++ b/Bugsnag/Helpers/BSGInternalErrorReporter.h @@ -35,6 +35,7 @@ NSString *_Nullable BSGErrorDescription(NSError *_Nullable error); // MARK: - +BSG_OBJC_DIRECT_MEMBERS @interface BSGInternalErrorReporter : NSObject @property (class, nullable, nonatomic) BSGInternalErrorReporter *sharedInstance; @@ -46,18 +47,6 @@ NSString *_Nullable BSGErrorDescription(NSError *_Nullable error); - (instancetype)init UNAVAILABLE_ATTRIBUTE; -/// Reports an error to Bugsnag's internal bugsnag-cocoa project dashboard. -/// @param errorClass The class of error which occurred. This field is used to group the errors together so should not contain any contextual -/// information that would prevent correct grouping. This would ordinarily be the Exception name when dealing with an exception. -/// @param context The context to associate with this event. Errors are grouped by errorClass:context -/// @param message The error message associated with the error. Usually this will contain some information about this specific instance of the error -/// and is not used to group the errors. -/// @param diagnostics JSON compatible information to include in the `BugsnagDiagnostics` metadata section. -- (void)reportErrorWithClass:(NSString *)errorClass - context:(nullable NSString *)context - message:(nullable NSString *)message - diagnostics:(nullable NSDictionary *)diagnostics; - - (void)reportException:(NSException *)exception diagnostics:(nullable NSDictionary *)diagnostics groupingHash:(nullable NSString *)groupingHash; @@ -81,4 +70,20 @@ NSString *_Nullable BSGErrorDescription(NSError *_Nullable error); @end +@interface BSGInternalErrorReporter (/* not objc_direct */) + +/// Reports an error to Bugsnag's internal bugsnag-cocoa project dashboard. +/// @param errorClass The class of error which occurred. This field is used to group the errors together so should not contain any contextual +/// information that would prevent correct grouping. This would ordinarily be the Exception name when dealing with an exception. +/// @param context The context to associate with this event. Errors are grouped by errorClass:context +/// @param message The error message associated with the error. Usually this will contain some information about this specific instance of the error +/// and is not used to group the errors. +/// @param diagnostics JSON compatible information to include in the `BugsnagDiagnostics` metadata section. +- (void)reportErrorWithClass:(NSString *)errorClass + context:(nullable NSString *)context + message:(nullable NSString *)message + diagnostics:(nullable NSDictionary *)diagnostics; + +@end + NS_ASSUME_NONNULL_END diff --git a/Bugsnag/Helpers/BSGInternalErrorReporter.m b/Bugsnag/Helpers/BSGInternalErrorReporter.m index 1dead108b..df1bb6dc7 100644 --- a/Bugsnag/Helpers/BSGInternalErrorReporter.m +++ b/Bugsnag/Helpers/BSGInternalErrorReporter.m @@ -53,6 +53,7 @@ // MARK: - +BSG_OBJC_DIRECT_MEMBERS @interface BSGInternalErrorReporter () @property (weak, nullable, nonatomic) id dataSource; @@ -61,6 +62,7 @@ @interface BSGInternalErrorReporter () @end +BSG_OBJC_DIRECT_MEMBERS @implementation BSGInternalErrorReporter static BSGInternalErrorReporter *sharedInstance_; diff --git a/Bugsnag/Helpers/BSG_RFC3339DateTool.h b/Bugsnag/Helpers/BSG_RFC3339DateTool.h index b38bcb492..46214d5b0 100644 --- a/Bugsnag/Helpers/BSG_RFC3339DateTool.h +++ b/Bugsnag/Helpers/BSG_RFC3339DateTool.h @@ -24,9 +24,11 @@ #import +#import "BSGDefines.h" /** * Tool for converting to/from RFC3339 compliant date strings. */ +BSG_OBJC_DIRECT_MEMBERS @interface BSG_RFC3339DateTool : NSObject /** Convert a date to an RFC3339 string representation. diff --git a/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.h b/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.h index e73c6da8b..952c86786 100644 --- a/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.h +++ b/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.h @@ -26,6 +26,7 @@ #import +#import "BSGDefines.h" #import "BSG_KSCrashType.h" /** @@ -33,6 +34,7 @@ * * The crash reports will be located in $APP_HOME/Library/Caches/KSCrashReports */ +BSG_OBJC_DIRECT_MEMBERS @interface BSG_KSCrash : NSObject /** Get the singleton instance of the crash reporter. diff --git a/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashDoctor.h b/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashDoctor.h index 2f161903d..28d85584b 100644 --- a/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashDoctor.h +++ b/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashDoctor.h @@ -8,6 +8,9 @@ #import +#import "BSGDefines.h" + +BSG_OBJC_DIRECT_MEMBERS @interface BSG_KSCrashDoctor : NSObject - (NSString *)diagnoseCrash:(NSDictionary *)crashReport; diff --git a/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashDoctor.m b/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashDoctor.m index 5efc53a28..abff7eaee 100644 --- a/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashDoctor.m +++ b/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashDoctor.m @@ -12,6 +12,7 @@ #import "BSG_KSSystemInfo.h" #import "BugsnagLogger.h" +BSG_OBJC_DIRECT_MEMBERS @implementation BSG_KSCrashDoctor - (NSDictionary *)crashReport:(NSDictionary *)report { diff --git a/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.h b/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.h index 0ccfc536d..c7548f3d6 100644 --- a/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.h +++ b/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.h @@ -27,6 +27,8 @@ #import #import +#import "BSGDefines.h" + #define BSG_KSSystemField_AppUUID "app_uuid" #define BSG_KSSystemField_BinaryArch "binary_arch" #define BSG_KSSystemField_BundleID "CFBundleIdentifier" @@ -53,7 +55,7 @@ /** * Provides system information useful for a crash report. */ -BUGSNAG_EXTERN +BSG_OBJC_DIRECT_MEMBERS @interface BSG_KSSystemInfo : NSObject /** Get the system info. diff --git a/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m b/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m index 321c83f12..7c335ae18 100644 --- a/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m +++ b/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m @@ -109,6 +109,7 @@ static inline bool is_jailbroken() { } #endif +BSG_OBJC_DIRECT_MEMBERS @implementation BSG_KSSystemInfo // ============================================================================ diff --git a/Bugsnag/Metadata/BugsnagMetadata+Private.h b/Bugsnag/Metadata/BugsnagMetadata+Private.h index ec4303674..616f9ce13 100644 --- a/Bugsnag/Metadata/BugsnagMetadata+Private.h +++ b/Bugsnag/Metadata/BugsnagMetadata+Private.h @@ -8,10 +8,13 @@ #import "BugsnagInternals.h" +#import "BSGDefines.h" + NS_ASSUME_NONNULL_BEGIN typedef void (^ BSGMetadataObserver)(BugsnagMetadata *); +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagMetadata () #pragma mark Properties diff --git a/Bugsnag/Metadata/BugsnagMetadata.m b/Bugsnag/Metadata/BugsnagMetadata.m index 88b56f2a6..2c2c14747 100644 --- a/Bugsnag/Metadata/BugsnagMetadata.m +++ b/Bugsnag/Metadata/BugsnagMetadata.m @@ -32,6 +32,7 @@ #import "BugsnagLogger.h" +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagMetadata () @property(atomic, readwrite, strong) NSMutableArray *stateEventBlocks; @@ -45,6 +46,7 @@ @interface BugsnagMetadata () // MARK: - +BSG_OBJC_DIRECT_MEMBERS @implementation BugsnagMetadata - (instancetype)init { diff --git a/Bugsnag/Payload/BugsnagBreadcrumb+Private.h b/Bugsnag/Payload/BugsnagBreadcrumb+Private.h index fce17e9ed..72083260a 100644 --- a/Bugsnag/Payload/BugsnagBreadcrumb+Private.h +++ b/Bugsnag/Payload/BugsnagBreadcrumb+Private.h @@ -6,16 +6,16 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // +#import "BSGDefines.h" #import "BugsnagInternals.h" NS_ASSUME_NONNULL_BEGIN +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagBreadcrumb () - (BOOL)isValid; -- (nullable NSDictionary *)objectValue; - /// String representation of `timestamp` used to avoid unnecessary date <--> string conversions @property (copy, nullable, nonatomic) NSString *timestampString; diff --git a/Bugsnag/Payload/BugsnagBreadcrumb.m b/Bugsnag/Payload/BugsnagBreadcrumb.m index a19fdeaf1..f42bf4823 100644 --- a/Bugsnag/Payload/BugsnagBreadcrumb.m +++ b/Bugsnag/Payload/BugsnagBreadcrumb.m @@ -81,6 +81,7 @@ @interface BugsnagBreadcrumb () @end +BSG_OBJC_DIRECT_MEMBERS @implementation BugsnagBreadcrumb - (instancetype)init { diff --git a/Bugsnag/Payload/BugsnagError+Private.h b/Bugsnag/Payload/BugsnagError+Private.h index 5096ab81b..71d1a2f93 100644 --- a/Bugsnag/Payload/BugsnagError+Private.h +++ b/Bugsnag/Payload/BugsnagError+Private.h @@ -6,12 +6,14 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // +#import "BSGDefines.h" #import "BugsnagInternals.h" NS_ASSUME_NONNULL_BEGIN @class BugsnagThread; +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagError () - (instancetype)initWithKSCrashReport:(NSDictionary *)event stacktrace:(NSArray *)stacktrace; diff --git a/Bugsnag/Payload/BugsnagError.m b/Bugsnag/Payload/BugsnagError.m index 88cc90169..4710ac805 100644 --- a/Bugsnag/Payload/BugsnagError.m +++ b/Bugsnag/Payload/BugsnagError.m @@ -79,6 +79,7 @@ BSGErrorType BSGParseErrorType(NSString *errorType) { return diagnosis ?: reason ?: @""; } +BSG_OBJC_DIRECT_MEMBERS @implementation BugsnagError @dynamic type; diff --git a/Bugsnag/Payload/BugsnagEvent+Private.h b/Bugsnag/Payload/BugsnagEvent+Private.h index 4c0411e06..266e8cd78 100644 --- a/Bugsnag/Payload/BugsnagEvent+Private.h +++ b/Bugsnag/Payload/BugsnagEvent+Private.h @@ -6,11 +6,13 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // +#import "BSGDefines.h" #import "BSGFeatureFlagStore.h" #import "BugsnagInternals.h" NS_ASSUME_NONNULL_BEGIN +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagEvent () @property (copy, nonatomic) NSString *codeBundleId; diff --git a/Bugsnag/Payload/BugsnagEvent.m b/Bugsnag/Payload/BugsnagEvent.m index 541ffcada..60969a36c 100644 --- a/Bugsnag/Payload/BugsnagEvent.m +++ b/Bugsnag/Payload/BugsnagEvent.m @@ -127,6 +127,7 @@ id BSGLoadConfigValue(NSDictionary *report, NSString *valueName) { // MARK: - +BSG_OBJC_DIRECT_MEMBERS @implementation BugsnagEvent /** diff --git a/Bugsnag/Payload/BugsnagHandledState.m b/Bugsnag/Payload/BugsnagHandledState.m index 01251a481..53859d711 100644 --- a/Bugsnag/Payload/BugsnagHandledState.m +++ b/Bugsnag/Payload/BugsnagHandledState.m @@ -8,6 +8,7 @@ #import "BugsnagHandledState.h" +#import "BSGDefines.h" #import "BSGKeys.h" BSGSeverity BSGParseSeverity(NSString *severity) { @@ -49,6 +50,7 @@ BSGSeverity BSGParseSeverity(NSString *severity) { static NSString *const kUserSpecifiedSeverity = @"userSpecifiedSeverity"; static NSString *const kUserCallbackSetSeverity = @"userCallbackSetSeverity"; +BSG_OBJC_DIRECT_MEMBERS @implementation BugsnagHandledState + (instancetype)handledStateFromJson:(NSDictionary *)json { diff --git a/Bugsnag/Payload/BugsnagSession+Private.h b/Bugsnag/Payload/BugsnagSession+Private.h index 9f47a5673..4f5df709d 100644 --- a/Bugsnag/Payload/BugsnagSession+Private.h +++ b/Bugsnag/Payload/BugsnagSession+Private.h @@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN @class BugsnagUser; +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagSession () #pragma mark Initializers diff --git a/Bugsnag/Payload/BugsnagSession.m b/Bugsnag/Payload/BugsnagSession.m index d9bf16b7a..fbe329f06 100644 --- a/Bugsnag/Payload/BugsnagSession.m +++ b/Bugsnag/Payload/BugsnagSession.m @@ -15,6 +15,7 @@ #import "BugsnagDevice+Private.h" #import "BugsnagUser+Private.h" +BSG_OBJC_DIRECT_MEMBERS @implementation BugsnagSession - (instancetype)initWithId:(NSString *)sessionId @@ -33,7 +34,7 @@ - (instancetype)initWithId:(NSString *)sessionId } - (instancetype)copyWithZone:(NSZone *)zone { - BugsnagSession *session = [[[self class] allocWithZone:zone] + BugsnagSession *session = [[BugsnagSession allocWithZone:zone] initWithId:self.id startedAt:self.startedAt user:self.user diff --git a/Bugsnag/Payload/BugsnagStackframe+Private.h b/Bugsnag/Payload/BugsnagStackframe+Private.h index 69632bbe2..83cd44e06 100644 --- a/Bugsnag/Payload/BugsnagStackframe+Private.h +++ b/Bugsnag/Payload/BugsnagStackframe+Private.h @@ -6,10 +6,12 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // +#import "BSGDefines.h" #import "BugsnagInternals.h" NS_ASSUME_NONNULL_BEGIN +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagStackframe () + (NSArray *)stackframesWithBacktrace:(uintptr_t *)backtrace length:(NSUInteger)length; diff --git a/Bugsnag/Payload/BugsnagStackframe.m b/Bugsnag/Payload/BugsnagStackframe.m index 347c1e145..7483d7f09 100644 --- a/Bugsnag/Payload/BugsnagStackframe.m +++ b/Bugsnag/Payload/BugsnagStackframe.m @@ -26,6 +26,7 @@ // MARK: - +BSG_OBJC_DIRECT_MEMBERS @implementation BugsnagStackframe static NSDictionary * _Nullable FindImage(NSArray *images, uintptr_t addr) { diff --git a/Bugsnag/Payload/BugsnagStacktrace.h b/Bugsnag/Payload/BugsnagStacktrace.h index 34c12457d..23ce524f1 100644 --- a/Bugsnag/Payload/BugsnagStacktrace.h +++ b/Bugsnag/Payload/BugsnagStacktrace.h @@ -8,11 +8,14 @@ #import +#import "BSGDefines.h" + @class BugsnagStackframe; /** * Representation of a stacktrace in a bugsnag error report */ +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagStacktrace : NSObject - (instancetype)initWithTrace:(NSArray *)trace diff --git a/Bugsnag/Payload/BugsnagStacktrace.m b/Bugsnag/Payload/BugsnagStacktrace.m index 5d9e8482b..d9ccd304d 100644 --- a/Bugsnag/Payload/BugsnagStacktrace.m +++ b/Bugsnag/Payload/BugsnagStacktrace.m @@ -11,6 +11,7 @@ #import "BSGKeys.h" #import "BugsnagStackframe+Private.h" +BSG_OBJC_DIRECT_MEMBERS @implementation BugsnagStacktrace + (instancetype)stacktraceFromJson:(NSArray *)json { diff --git a/Bugsnag/Payload/BugsnagThread+Private.h b/Bugsnag/Payload/BugsnagThread+Private.h index 834959d27..41dad15e8 100644 --- a/Bugsnag/Payload/BugsnagThread+Private.h +++ b/Bugsnag/Payload/BugsnagThread+Private.h @@ -11,6 +11,7 @@ NS_ASSUME_NONNULL_BEGIN +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagThread () - (instancetype)initWithId:(nullable NSString *)identifier diff --git a/Bugsnag/Payload/BugsnagThread.m b/Bugsnag/Payload/BugsnagThread.m index 9e8ccab72..1ed5d6307 100644 --- a/Bugsnag/Payload/BugsnagThread.m +++ b/Bugsnag/Payload/BugsnagThread.m @@ -68,6 +68,7 @@ BSGThreadType BSGParseThreadType(NSString *type) { return type == BSGThreadTypeCocoa ? @"cocoa" : @"reactnativejs"; } +BSG_OBJC_DIRECT_MEMBERS @implementation BugsnagThread + (instancetype)threadFromJson:(NSDictionary *)json { diff --git a/Bugsnag/Payload/BugsnagUser+Private.h b/Bugsnag/Payload/BugsnagUser+Private.h index b12c6db59..dac0b83a1 100644 --- a/Bugsnag/Payload/BugsnagUser+Private.h +++ b/Bugsnag/Payload/BugsnagUser+Private.h @@ -6,10 +6,12 @@ // Copyright © 2020 Bugsnag Inc. All rights reserved. // +#import "BSGDefines.h" #import "BugsnagInternals.h" NS_ASSUME_NONNULL_BEGIN +BSG_OBJC_DIRECT_MEMBERS @interface BugsnagUser () - (instancetype)initWithId:(nullable NSString *)id name:(nullable NSString *)name emailAddress:(nullable NSString *)emailAddress; diff --git a/Bugsnag/Payload/BugsnagUser.m b/Bugsnag/Payload/BugsnagUser.m index 403adf7f6..63492460c 100644 --- a/Bugsnag/Payload/BugsnagUser.m +++ b/Bugsnag/Payload/BugsnagUser.m @@ -10,6 +10,7 @@ #import "BSG_KSSystemInfo.h" +BSG_OBJC_DIRECT_MEMBERS @implementation BugsnagUser - (instancetype)initWithDictionary:(NSDictionary *)dict { diff --git a/Bugsnag/Storage/BSGFileLocations.h b/Bugsnag/Storage/BSGFileLocations.h index 5ad3cdf01..bbf56de03 100644 --- a/Bugsnag/Storage/BSGFileLocations.h +++ b/Bugsnag/Storage/BSGFileLocations.h @@ -8,8 +8,11 @@ #import +#import "BSGDefines.h" + NS_ASSUME_NONNULL_BEGIN +BSG_OBJC_DIRECT_MEMBERS @interface BSGFileLocations : NSObject @property (readonly, nonatomic) NSString *breadcrumbs; diff --git a/Bugsnag/Storage/BSGFileLocations.m b/Bugsnag/Storage/BSGFileLocations.m index c1ec8a9ab..02c3a7be3 100644 --- a/Bugsnag/Storage/BSGFileLocations.m +++ b/Bugsnag/Storage/BSGFileLocations.m @@ -68,6 +68,7 @@ static BOOL ensureDirExists(NSString *path) { return subdirPath; } +BSG_OBJC_DIRECT_MEMBERS @implementation BSGFileLocations + (instancetype) current { diff --git a/Bugsnag/Storage/BSGStorageMigratorV0V1.h b/Bugsnag/Storage/BSGStorageMigratorV0V1.h index b133e2683..44faf97c7 100644 --- a/Bugsnag/Storage/BSGStorageMigratorV0V1.h +++ b/Bugsnag/Storage/BSGStorageMigratorV0V1.h @@ -8,8 +8,11 @@ #import +#import "BSGDefines.h" + NS_ASSUME_NONNULL_BEGIN +BSG_OBJC_DIRECT_MEMBERS @interface BSGStorageMigratorV0V1 : NSObject + (BOOL) migrate; diff --git a/Bugsnag/Storage/BSGStorageMigratorV0V1.m b/Bugsnag/Storage/BSGStorageMigratorV0V1.m index 632cfa3bf..58c1fc653 100644 --- a/Bugsnag/Storage/BSGStorageMigratorV0V1.m +++ b/Bugsnag/Storage/BSGStorageMigratorV0V1.m @@ -11,6 +11,7 @@ #import "BSGFileLocations.h" #import "BugsnagLogger.h" +BSG_OBJC_DIRECT_MEMBERS @implementation BSGStorageMigratorV0V1 static void RemoveItem(NSFileManager *fileManager, NSString *path) { From ab3a590d4ff9662c8c646d7f2a7186d202d6312c Mon Sep 17 00:00:00 2001 From: Nick Dowell Date: Mon, 12 Sep 2022 14:47:04 +0100 Subject: [PATCH 2/2] Fix Xcode 11 build issue with __attribute__((objc_direct_members)) --- Bugsnag/Helpers/BSGDefines.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Bugsnag/Helpers/BSGDefines.h b/Bugsnag/Helpers/BSGDefines.h index 6237f9fd2..2b37308a4 100644 --- a/Bugsnag/Helpers/BSGDefines.h +++ b/Bugsnag/Helpers/BSGDefines.h @@ -33,7 +33,7 @@ // See https://reviews.llvm.org/D69991 // Overridden when building for unit testing to make private interfaces accessible. #ifndef BSG_OBJC_DIRECT_MEMBERS -#if __has_attribute(objc_direct_members) +#if __has_attribute(objc_direct_members) && (__clang_major__ > 11) #define BSG_OBJC_DIRECT_MEMBERS __attribute__((objc_direct_members)) #else #define BSG_OBJC_DIRECT_MEMBERS