Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PLAT-8737] Use __attribute__((objc_direct_members)) #1479

Merged
merged 2 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Bugsnag.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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)",
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@

#import <Bugsnag/BugsnagBreadcrumb.h>

#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
Expand Down
20 changes: 20 additions & 0 deletions Bugsnag/Breadcrumbs/BSGNotificationBreadcrumbs.m
Original file line number Diff line number Diff line change
Expand Up @@ -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<NSNotificationName, NSString *> *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
Expand Down
3 changes: 3 additions & 0 deletions Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@

#import <Foundation/Foundation.h>

#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;
Expand Down
1 change: 1 addition & 0 deletions Bugsnag/Breadcrumbs/BugsnagBreadcrumbs.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ @interface BugsnagBreadcrumbs ()

#pragma mark -

BSG_OBJC_DIRECT_MEMBERS
@implementation BugsnagBreadcrumbs

- (instancetype)initWithConfiguration:(BugsnagConfiguration *)config {
Expand Down
5 changes: 3 additions & 2 deletions Bugsnag/Bugsnag+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@

#import <Bugsnag/Bugsnag.h>

#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
1 change: 1 addition & 0 deletions Bugsnag/Bugsnag.m
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

static BugsnagClient *bsg_g_bugsnag_client = NULL;

BSG_OBJC_DIRECT_MEMBERS
@implementation Bugsnag

+ (BugsnagClient *_Nonnull)start {
Expand Down
35 changes: 20 additions & 15 deletions Bugsnag/BugsnagSessionTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

NS_ASSUME_NONNULL_BEGIN

BSG_OBJC_DIRECT_MEMBERS
@interface BugsnagSessionTracker : NSObject

/**
Expand All @@ -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
Expand All @@ -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
2 changes: 2 additions & 0 deletions Bugsnag/BugsnagSessionTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
*/
static NSTimeInterval const BSGNewSessionBackgroundDuration = 30;

BSG_OBJC_DIRECT_MEMBERS
@interface BugsnagSessionTracker ()
@property (strong, nonatomic) BugsnagConfiguration *config;
@property (weak, nonatomic) BugsnagClient *client;
@property (strong, nonatomic) NSDate *backgroundStartTime;
@property (nonatomic) NSMutableDictionary *extraRuntimeInfo;
@end

BSG_OBJC_DIRECT_MEMBERS
@implementation BugsnagSessionTracker

- (instancetype)initWithConfig:(BugsnagConfiguration *)config client:(BugsnagClient *)client {
Expand Down
2 changes: 2 additions & 0 deletions Bugsnag/BugsnagSystemState.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#import <Bugsnag/BugsnagConfiguration.h>

#import "BSGDefines.h"
#import "BSGKeys.h"

#define SYSTEMSTATE_KEY_APP @"app"
Expand All @@ -19,6 +20,7 @@

NS_ASSUME_NONNULL_BEGIN

BSG_OBJC_DIRECT_MEMBERS
@interface BugsnagSystemState : NSObject

@property(readonly,nonatomic) NSDictionary *lastLaunchState;
Expand Down
2 changes: 2 additions & 0 deletions Bugsnag/BugsnagSystemState.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ id blankIfNil(id value) {
return dictionary;
}

BSG_OBJC_DIRECT_MEMBERS
@interface BugsnagSystemState ()

@property(readwrite,atomic) NSDictionary *currentLaunchState;
Expand All @@ -114,6 +115,7 @@ @interface BugsnagSystemState ()

@end

BSG_OBJC_DIRECT_MEMBERS
@implementation BugsnagSystemState

- (instancetype)initWithConfiguration:(BugsnagConfiguration *)config {
Expand Down
2 changes: 2 additions & 0 deletions Bugsnag/Client/BugsnagClient+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2020 Bugsnag Inc. All rights reserved.
//

#import "BSGDefines.h"
#import "BugsnagInternals.h"

@class BSGAppHangDetector;
Expand All @@ -21,6 +22,7 @@

NS_ASSUME_NONNULL_BEGIN

BSG_OBJC_DIRECT_MEMBERS
@interface BugsnagClient ()

#pragma mark Properties
Expand Down
10 changes: 10 additions & 0 deletions Bugsnag/Client/BugsnagClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ static void BSSerializeDataCrashHandler(const BSG_KSCrashReportWriter *writer) {

// MARK: -

BSG_OBJC_DIRECT_MEMBERS
@interface BugsnagClient () <BSGBreadcrumbSink, BSGInternalErrorReporterDataSource>

@property (nonatomic) BSGNotificationBreadcrumbs *notificationBreadcrumbs;
Expand All @@ -163,6 +164,14 @@ @interface BugsnagClient () <BSGBreadcrumbSink, BSGInternalErrorReporterDataSour

@end

@interface BugsnagClient (/* not objc_direct */)

- (void)appLaunchTimerFired:(NSTimer *)timer;

- (void)applicationWillTerminate:(NSNotification *)notification;

@end

#if BSG_HAVE_APP_HANG_DETECTION
@interface BugsnagClient () <BSGAppHangDetectorDelegate>
@end
Expand All @@ -174,6 +183,7 @@ @interface BugsnagClient () <BSGAppHangDetectorDelegate>
__attribute__((annotate("oclint:suppress[long class]")))
__attribute__((annotate("oclint:suppress[too many methods]")))
#endif
BSG_OBJC_DIRECT_MEMBERS
@implementation BugsnagClient

- (instancetype)initWithConfiguration:(BugsnagConfiguration *)configuration {
Expand Down
5 changes: 5 additions & 0 deletions Bugsnag/Configuration/BugsnagConfiguration+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,4 +52,7 @@ NS_ASSUME_NONNULL_BEGIN

@end

@interface BugsnagConfiguration (/* not objc_direct */) <NSCopying>
@end

NS_ASSUME_NONNULL_END
1 change: 1 addition & 0 deletions Bugsnag/Configuration/BugsnagConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
// MARK: - BugsnagConfiguration
// =============================================================================

BSG_OBJC_DIRECT_MEMBERS
@implementation BugsnagConfiguration

+ (instancetype _Nonnull)loadConfig {
Expand Down
1 change: 1 addition & 0 deletions Bugsnag/Delivery/BSGConnectivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
3 changes: 3 additions & 0 deletions Bugsnag/Delivery/BSGEventUploadFileOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<BSGEventUploadOperationDelegate>)delegate;
Expand Down
Loading