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

Fix iOS 8 functional issues and annoyances #40

Merged
merged 7 commits into from
May 27, 2015
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: 1 addition & 1 deletion BugshotKit/BSKWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ - (void)dealloc

- (void)applicationWillEnterForeground:(NSNotification *)n
{
[BugshotKit dismissAninmated:NO completion:NULL];
[BugshotKit dismissAnimated:NO completion:NULL];
}

- (void)applicationDidBecomeActive:(NSNotification *)n
Expand Down
2 changes: 1 addition & 1 deletion BugshotKit/BugshotKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ typedef enum : NSUInteger {

/* You can also always show it manually */
+ (void)show;
+ (void)dismissAninmated:(BOOL)animated completion:(void(^)())completion;
+ (void)dismissAnimated:(BOOL)animated completion:(void(^)())completion;

+ (instancetype)sharedManager;
- (void)clearLog;
Expand Down
40 changes: 33 additions & 7 deletions BugshotKit/BugshotKit.m
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ - (void)handleOpenGesture:(UIGestureRecognizer *)sender
self.snapshotImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

if (interfaceOrientation != UIInterfaceOrientationPortrait) {
if ([UIDevice currentDevice].systemVersion.floatValue < 8.0f && interfaceOrientation != UIInterfaceOrientationPortrait) {
self.snapshotImage = [[UIImage alloc] initWithCGImage:self.snapshotImage.CGImage scale:UIScreen.mainScreen.scale orientation:(
interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ? UIImageOrientationDown : (
interfaceOrientation == UIInterfaceOrientationLandscapeLeft ? UIImageOrientationRight : UIImageOrientationLeft
Expand All @@ -424,11 +424,11 @@ - (void)handleOpenGesture:(UIGestureRecognizer *)sender
BSKNavigationController *nc = [[BSKNavigationController alloc] initWithRootViewController:mvc lockedToRotation:self.window.rootViewController.interfaceOrientation];
self.presentedNavigationController = nc;
nc.navigationBar.tintColor = BugshotKit.sharedManager.annotationFillColor;
nc.navigationBar.titleTextAttributes = @{ NSForegroundColorAttributeName:BugshotKit.sharedManager.annotationFillColor };
[presentingViewController presentViewController:nc animated:YES completion:NULL];
}

+ (void)dismissAninmated:(BOOL)animated completion:(void(^)())completion
{
+ (void)dismissAnimated:(BOOL)animated completion:(void(^)())completion {
UIViewController *presentingVC = BugshotKit.sharedManager.presentedNavigationController.presentingViewController;
if (presentingVC) {
[presentingVC dismissViewControllerAnimated:animated completion:completion];
Expand Down Expand Up @@ -509,6 +509,21 @@ - (void)addLogMessage:(NSString *)message timestamp:(NSTimeInterval)timestamp
}
}

// Because aslresponse_next is now deprecated.
asl_object_t SystemSafeASLNext(asl_object_t r) {
if ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f) {
return asl_next(r);
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// The deprecation attribute incorrectly states that the replacement method, asl_next()
// is available in __IPHONE_7_0; asl_next() first appears in __IPHONE_8_0.
// This would require both a compile and runtime check to properly implement the new method
// while the minimum deployment target for this project remains iOS 7.0.
return aslresponse_next(r);
#pragma clang diagnostic pop
}

// assumed to always be in logQueue
- (BOOL)updateFromASL
{
Expand All @@ -521,7 +536,7 @@ - (BOOL)updateFromASL
aslresponse r = asl_search(NULL, q);
BOOL foundNewEntries = NO;

while ( (m = aslresponse_next(r)) ) {
while ( (m = SystemSafeASLNext(r)) ) {
if (myPID != atol(asl_get(m, ASL_KEY_PID))) continue;

// dupe checking
Expand All @@ -537,7 +552,18 @@ - (BOOL)updateFromASL
[self addLogMessage:[NSString stringWithUTF8String:msg] timestamp:msgTime];
}

aslresponse_free(r);
if ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f) {
asl_release(r);
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
// The deprecation attribute incorrectly states that the replacement method, asl_release()
// is available in __IPHONE_7_0; asl_release() first appears in __IPHONE_8_0.
// This would require both a compile and runtime check to properly implement the new method
// while the minimum deployment target for this project remains iOS 7.0.
aslresponse_free(r);
#pragma clang diagnostic pop
}
asl_free(q);

return foundNewEntries;
Expand Down Expand Up @@ -594,8 +620,7 @@ + (BOOL)isProbablyAppStoreBuild
{
#if TARGET_IPHONE_SIMULATOR
return NO;
#endif

#else
// Adapted from https://github.com/blindsightcorp/BSMobileProvision

NSString *binaryMobileProvision = [NSString stringWithContentsOfFile:[NSBundle.mainBundle pathForResource:@"embedded" ofType:@"mobileprovision"] encoding:NSISOLatin1StringEncoding error:NULL];
Expand All @@ -618,6 +643,7 @@ + (BOOL)isProbablyAppStoreBuild
if (mobileProvision[@"ProvisionedDevices"] && ((NSDictionary *)mobileProvision[@"ProvisionedDevices"]).count) return NO; // development or ad-hoc

return YES; // expected development/enterprise/ad-hoc entitlements not found
#endif
}


Expand Down