Skip to content

Commit

Permalink
Add tvOS support
Browse files Browse the repository at this point in the history
  • Loading branch information
kattrali committed Jul 21, 2016
1 parent 1bfc59d commit 5313ce5
Show file tree
Hide file tree
Showing 13 changed files with 749 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ matrix:
env: SDK=iphonesimulator9.3
- osx_image: xcode7.2
env: SDK=iphonesimulator9.2
- osx_image: xcode7.3
env: SDK=appletvsimulator9.2
install: make bootstrap
script: make test
3 changes: 2 additions & 1 deletion Bugsnag.podspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"frameworks": "Foundation",
"platforms": {
"ios": "6.0",
"osx": "10.8"
"osx": "10.8",
"tvos": "9.0"
},
"source_files": [
"Source/*.{m,h,mm,c,cpp}"
Expand Down
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ ifeq ($(BUILD_OSX), 1)
BUILD_FLAGS=-workspace OSX.xcworkspace -scheme Bugsnag
BUILD_ONLY_FLAGS=CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
else
PLATFORM=iOS
RELEASE_DIR=Release-iphoneos
BUILD_FLAGS=-workspace iOS.xcworkspace -scheme Bugsnag
BUILD_ONLY_FLAGS=-sdk $(SDK) -destination "platform=iOS Simulator,name=iPhone 5" -configuration Debug
ifeq ($(SDK),appletvsimulator9.2)
PLATFORM=tvOS
BUILD_FLAGS=-workspace tvOS.xcworkspace -scheme Bugsnag
BUILD_ONLY_FLAGS=-sdk $(SDK) -configuration Debug
else
PLATFORM=iOS
RELEASE_DIR=Release-iphoneos
BUILD_FLAGS=-workspace iOS.xcworkspace -scheme Bugsnag
BUILD_ONLY_FLAGS=-sdk $(SDK) -destination "platform=iOS Simulator,name=iPhone 5" -configuration Debug
endif
endif
XCODEBUILD=set -o pipefail && xcodebuild
VERSION=$(shell cat VERSION)
Expand Down
28 changes: 22 additions & 6 deletions Source/BugsnagNotifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@ - (void) start {

[self performSelectorInBackground:@selector(sendPendingReports) withObject:nil];
[self updateAutomaticBreadcrumbDetectionSettings];
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
#if TARGET_OS_TV
[self.details setValue:@"tvOS Bugsnag Notifier" forKey:@"name"];
#elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
[self.details setValue:@"iOS Bugsnag Notifier" forKey:@"name"];

[[NSNotificationCenter defaultCenter]
Expand Down Expand Up @@ -252,7 +254,8 @@ - (void) metaDataChanged:(BugsnagMetaData *)metaData {
}
}

#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
#if TARGET_OS_TV
#elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
- (void)batteryChanged:(NSNotification *)notif {
NSNumber *batteryLevel =
[NSNumber numberWithFloat:[UIDevice currentDevice].batteryLevel];
Expand Down Expand Up @@ -348,7 +351,16 @@ - (void)updateAutomaticBreadcrumbDetectionSettings {
}

- (NSArray <NSString *>*)automaticBreadcrumbStateEvents {
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
#if TARGET_OS_TV
return @[NSUndoManagerDidUndoChangeNotification,
NSUndoManagerDidRedoChangeNotification,
UIWindowDidBecomeVisibleNotification,
UIWindowDidBecomeHiddenNotification,
UIWindowDidBecomeKeyNotification,
UIWindowDidResignKeyNotification,
UIScreenBrightnessDidChangeNotification,
UITableViewSelectionDidChangeNotification];
#elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
return @[UIWindowDidBecomeHiddenNotification,
UIWindowDidBecomeVisibleNotification,
UIApplicationWillTerminateNotification,
Expand Down Expand Up @@ -396,7 +408,9 @@ - (void)updateAutomaticBreadcrumbDetectionSettings {
}

- (NSArray <NSString *>*)automaticBreadcrumbMenuItemEvents {
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
#if TARGET_OS_TV
return @[];
#elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
return nil;
#elif TARGET_OS_MAC
return @[NSMenuWillSendActionNotification];
Expand Down Expand Up @@ -426,7 +440,8 @@ - (void)sendBreadcrumbForNotification:(NSNotification *)note {
}

- (void)sendBreadcrumbForMenuItemNotification:(NSNotification *)notif {
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
#if TARGET_OS_TV
#elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
#elif TARGET_OS_MAC
NSMenuItem *menuItem = [[notif userInfo] valueForKey:@"MenuItem"];
if ([menuItem isKindOfClass:[NSMenuItem class]]) {
Expand All @@ -442,7 +457,8 @@ - (void)sendBreadcrumbForMenuItemNotification:(NSNotification *)notif {
}

- (void)sendBreadcrumbForControlNotification:(NSNotification *)note {
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
#if TARGET_OS_TV
#elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
UIControl* control = note.object;
[Bugsnag leaveBreadcrumbWithBlock:^(BugsnagBreadcrumb *_Nonnull breadcrumb) {
breadcrumb.type = BSGBreadcrumbTypeUser;
Expand Down
4 changes: 3 additions & 1 deletion Tests/BugsnagSinkTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ - (void)testCorrectNotifierKeys {

- (void)testNotifierName {
NSString *name = self.processedData[@"notifier"][@"name"];
#if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
#if TARGET_OS_TV
XCTAssertEqualObjects(name, @"tvOS Bugsnag Notifier");
#elif TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE
XCTAssertEqualObjects(name, @"iOS Bugsnag Notifier");
#else
XCTAssertEqualObjects(name, @"OSX Bugsnag Notifier");
Expand Down
10 changes: 10 additions & 0 deletions tvOS.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5313ce5

Please sign in to comment.