-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove link-time dependency on UIKit
- Loading branch information
1 parent
306289b
commit b6bb174
Showing
10 changed files
with
118 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// BSGUIKit.h | ||
// Bugsnag | ||
// | ||
// Created by Nick Dowell on 01/12/2020. | ||
// Copyright © 2020 Bugsnag Inc. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
// 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. | ||
|
||
#define UIAPPLICATION NSClassFromString(@"UIApplication") | ||
#define UIDEVICE NSClassFromString(@"UIDevice") | ||
|
||
#define UIApplicationDidBecomeActiveNotification @"UIApplicationDidBecomeActiveNotification" | ||
#define UIApplicationDidEnterBackgroundNotification @"UIApplicationDidEnterBackgroundNotification" | ||
#define UIApplicationDidReceiveMemoryWarningNotification @"UIApplicationDidReceiveMemoryWarningNotification" | ||
#define UIApplicationUserDidTakeScreenshotNotification @"UIApplicationUserDidTakeScreenshotNotification" | ||
#define UIApplicationWillEnterForegroundNotification @"UIApplicationWillEnterForegroundNotification" | ||
#define UIApplicationWillResignActiveNotification @"UIApplicationWillResignActiveNotification" | ||
#define UIApplicationWillTerminateNotification @"UIApplicationWillTerminateNotification" | ||
#define UIDeviceBatteryLevelDidChangeNotification @"UIDeviceBatteryLevelDidChangeNotification" | ||
#define UIDeviceBatteryStateDidChangeNotification @"UIDeviceBatteryStateDidChangeNotification" | ||
#define UIDeviceOrientationDidChangeNotification @"UIDeviceOrientationDidChangeNotification" | ||
#define UIKeyboardDidHideNotification @"UIKeyboardDidHideNotification" | ||
#define UIKeyboardDidShowNotification @"UIKeyboardDidShowNotification" | ||
#define UIMenuControllerDidHideMenuNotification @"UIMenuControllerDidHideMenuNotification" | ||
#define UIMenuControllerDidShowMenuNotification @"UIMenuControllerDidShowMenuNotification" | ||
#define UIScreenBrightnessDidChangeNotification @"UIScreenBrightnessDidChangeNotification" | ||
#define UITableViewSelectionDidChangeNotification @"UITableViewSelectionDidChangeNotification" | ||
#define UITextFieldTextDidBeginEditingNotification @"UITextFieldTextDidBeginEditingNotification" | ||
#define UITextFieldTextDidEndEditingNotification @"UITextFieldTextDidEndEditingNotification" | ||
#define UITextViewTextDidBeginEditingNotification @"UITextViewTextDidBeginEditingNotification" | ||
#define UITextViewTextDidEndEditingNotification @"UITextViewTextDidEndEditingNotification" | ||
#define UIWindowDidBecomeHiddenNotification @"UIWindowDidBecomeHiddenNotification" | ||
#define UIWindowDidBecomeKeyNotification @"UIWindowDidBecomeKeyNotification" | ||
#define UIWindowDidBecomeVisibleNotification @"UIWindowDidBecomeVisibleNotification" | ||
#define UIWindowDidResignKeyNotification @"UIWindowDidResignKeyNotification" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// UIKitTests.m | ||
// Bugsnag-iOSTests | ||
// | ||
// Created by Nick Dowell on 16/11/2020. | ||
// Copyright © 2020 Bugsnag Inc. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import <XCTest/XCTest.h> | ||
|
||
@interface UIKitTests : XCTestCase | ||
|
||
@end | ||
|
||
@implementation UIKitTests | ||
|
||
- (void)testNotificationNames { | ||
// The notifier uses hard-coded notification names so that it can avoid linking | ||
// to UIKit. These tests ensure that the hard-coded names match the SDK. | ||
#define ASSERT_NOTIFICATION_NAME(name) XCTAssertEqualObjects(name, @#name) | ||
ASSERT_NOTIFICATION_NAME(UIApplicationDidBecomeActiveNotification); | ||
ASSERT_NOTIFICATION_NAME(UIApplicationDidEnterBackgroundNotification); | ||
ASSERT_NOTIFICATION_NAME(UIApplicationDidReceiveMemoryWarningNotification); | ||
ASSERT_NOTIFICATION_NAME(UIApplicationUserDidTakeScreenshotNotification); | ||
ASSERT_NOTIFICATION_NAME(UIApplicationWillEnterForegroundNotification); | ||
ASSERT_NOTIFICATION_NAME(UIApplicationWillResignActiveNotification); | ||
ASSERT_NOTIFICATION_NAME(UIApplicationWillTerminateNotification); | ||
ASSERT_NOTIFICATION_NAME(UIDeviceBatteryLevelDidChangeNotification); | ||
ASSERT_NOTIFICATION_NAME(UIDeviceBatteryStateDidChangeNotification); | ||
ASSERT_NOTIFICATION_NAME(UIDeviceOrientationDidChangeNotification); | ||
ASSERT_NOTIFICATION_NAME(UIKeyboardDidHideNotification); | ||
ASSERT_NOTIFICATION_NAME(UIKeyboardDidShowNotification); | ||
ASSERT_NOTIFICATION_NAME(UIMenuControllerDidHideMenuNotification); | ||
ASSERT_NOTIFICATION_NAME(UIMenuControllerDidShowMenuNotification); | ||
ASSERT_NOTIFICATION_NAME(UIScreenBrightnessDidChangeNotification); | ||
ASSERT_NOTIFICATION_NAME(UITableViewSelectionDidChangeNotification); | ||
ASSERT_NOTIFICATION_NAME(UITextFieldTextDidBeginEditingNotification); | ||
ASSERT_NOTIFICATION_NAME(UITextFieldTextDidEndEditingNotification); | ||
ASSERT_NOTIFICATION_NAME(UITextViewTextDidBeginEditingNotification); | ||
ASSERT_NOTIFICATION_NAME(UITextViewTextDidEndEditingNotification); | ||
ASSERT_NOTIFICATION_NAME(UIWindowDidBecomeHiddenNotification); | ||
ASSERT_NOTIFICATION_NAME(UIWindowDidBecomeKeyNotification); | ||
ASSERT_NOTIFICATION_NAME(UIWindowDidBecomeVisibleNotification); | ||
ASSERT_NOTIFICATION_NAME(UIWindowDidResignKeyNotification); | ||
} | ||
|
||
@end |