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

Add tvOS support #113

Merged
merged 1 commit into from
Jul 23, 2016
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
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
2 changes: 1 addition & 1 deletion Source/BugsnagCrashReport.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
}

NSString *BSGParseErrorMessage(NSDictionary *report, NSDictionary *error, NSString *errorType) {
if ([errorType isEqualToString:@"mach"]) {
if ([errorType isEqualToString:@"mach"] || error[@"reason"] == nil) {
NSString *diagnosis = [report valueForKeyPath:@"crash.diagnosis"];
if (diagnosis && ![diagnosis hasPrefix:@"No diagnosis"]) {
return [[diagnosis componentsSeparatedByString:@"\n"] firstObject];
Expand Down
28 changes: 22 additions & 6 deletions Source/BugsnagNotifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,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 @@ -279,7 +281,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 @@ -375,7 +378,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 @@ -423,7 +435,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 @@ -453,7 +467,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 @@ -469,7 +484,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