diff --git a/MasterPassword/ObjC/Mac/MPMacAppDelegate.m b/MasterPassword/ObjC/Mac/MPMacAppDelegate.m index 78db532e..d20afa79 100644 --- a/MasterPassword/ObjC/Mac/MPMacAppDelegate.m +++ b/MasterPassword/ObjC/Mac/MPMacAppDelegate.m @@ -58,6 +58,33 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { +#ifdef CRASHLYTICS + NSString *crashlyticsAPIKey = [self crashlyticsAPIKey]; + if ([crashlyticsAPIKey length]) { + inf(@"Initializing Crashlytics"); +#if defined (DEBUG) || defined (ADHOC) + [Crashlytics sharedInstance].debugMode = YES; +#endif + [Crashlytics setUserIdentifier:[PearlKeyChain deviceIdentifier]]; + [Crashlytics setObjectValue:[PearlKeyChain deviceIdentifier] forKey:@"deviceIdentifier"]; + [Crashlytics setUserName:@"Anonymous"]; + [Crashlytics setObjectValue:@"Anonymous" forKey:@"username"]; + [Crashlytics startWithAPIKey:crashlyticsAPIKey]; + [[PearlLogger get] registerListener:^BOOL(PearlLogMessage *message) { + PearlLogLevel level = PearlLogLevelInfo; + if ([[MPConfig get].sendInfo boolValue]) + level = PearlLogLevelDebug; + + if (message.level >= level) + CLSLog( @"%@", [message messageDescription] ); + + return YES; + }]; + CLSLog( @"Crashlytics (%@) initialized for: %@ v%@.", // + [Crashlytics sharedInstance].version, [PearlInfoPlist get].CFBundleName, [PearlInfoPlist get].CFBundleVersion ); + } +#endif + // Setup delegates and listeners. [MPConfig get].delegate = self; __weak id weakSelf = self; @@ -605,4 +632,25 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven [[NSNotificationCenter defaultCenter] postNotificationName:MPCheckConfigNotification object:NSStringFromSelector( configKey )]; } +#pragma mark - Crashlytics + +- (NSDictionary *)crashlyticsInfo { + + static NSDictionary *crashlyticsInfo = nil; + if (crashlyticsInfo == nil) + crashlyticsInfo = [[NSDictionary alloc] initWithContentsOfURL: + [[NSBundle mainBundle] URLForResource:@"Crashlytics" withExtension:@"plist"]]; + + return crashlyticsInfo; +} + +- (NSString *)crashlyticsAPIKey { + + NSString *crashlyticsAPIKey = NSNullToNil( [[self crashlyticsInfo] valueForKeyPath:@"API Key"] ); + if (![crashlyticsAPIKey length]) + wrn( @"Crashlytics API key not set. Crash logs won't be recorded." ); + + return crashlyticsAPIKey; +} + @end diff --git a/MasterPassword/ObjC/Mac/MasterPassword-Mac.xcodeproj/project.pbxproj b/MasterPassword/ObjC/Mac/MasterPassword-Mac.xcodeproj/project.pbxproj index 612469cc..53c8927e 100644 --- a/MasterPassword/ObjC/Mac/MasterPassword-Mac.xcodeproj/project.pbxproj +++ b/MasterPassword/ObjC/Mac/MasterPassword-Mac.xcodeproj/project.pbxproj @@ -2213,7 +2213,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = "/bin/bash -e"; - shellScript = "../../../External/Mac/Crashlytics.framework/run \\\n \"$(/usr/libexec/PlistBuddy -c \"Print :'API Key'\" ../../Resources/Crashlytics/Crashlytics.plist)\""; + shellScript = "../../../External/Mac/Crashlytics.framework/run \\\n \"$(/usr/libexec/PlistBuddy -c \"Print :'API Key'\" ../../Resources/Crashlytics/Crashlytics.plist)\" 410fb41450e3a2e50fa8357682d812ecd3e1846f2141a99bdb9d3a6a981ad69c"; showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ @@ -2481,6 +2481,7 @@ "$(inherited)", "NDEBUG=1", "NS_BLOCK_ASSERTIONS=1", + "CRASHLYTICS=1", ); GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; @@ -2647,6 +2648,7 @@ "$(inherited)", "NDEBUG=1", "NS_BLOCK_ASSERTIONS=1", + "CRASHLYTICS=1", ); GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; diff --git a/MasterPassword/ObjC/Mac/MasterPassword-Prefix.pch b/MasterPassword/ObjC/Mac/MasterPassword-Prefix.pch index d5ca083f..12612c75 100644 --- a/MasterPassword/ObjC/Mac/MasterPassword-Prefix.pch +++ b/MasterPassword/ObjC/Mac/MasterPassword-Prefix.pch @@ -2,6 +2,10 @@ // Prefix header for all source files of the 'MasterPassword' target in the 'MasterPassword' project // +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8 +#warning "This project uses features only available in Mac OS X 10.8 and later." +#endif + #import "Pearl-Prefix.pch" #ifdef __OBJC__ @@ -10,6 +14,10 @@ #import #import +#ifdef CRASHLYTICS +#import +#endif + #import "MPTypes.h" #import "MPMacConfig.h" diff --git a/MasterPassword/ObjC/Mac/MasterPassword.entitlements b/MasterPassword/ObjC/Mac/MasterPassword.entitlements index 63355c1b..32c0b065 100644 --- a/MasterPassword/ObjC/Mac/MasterPassword.entitlements +++ b/MasterPassword/ObjC/Mac/MasterPassword.entitlements @@ -10,5 +10,7 @@ com.apple.security.files.user-selected.read-write + com.apple.security.network.client + diff --git a/MasterPassword/ObjC/iOS/MPiOSAppDelegate.m b/MasterPassword/ObjC/iOS/MPiOSAppDelegate.m index 2711023a..7b751758 100644 --- a/MasterPassword/ObjC/iOS/MPiOSAppDelegate.m +++ b/MasterPassword/ObjC/iOS/MPiOSAppDelegate.m @@ -53,7 +53,7 @@ [Crashlytics startWithAPIKey:crashlyticsAPIKey]; [[PearlLogger get] registerListener:^BOOL(PearlLogMessage *message) { PearlLogLevel level = PearlLogLevelInfo; - if ([[MPiOSConfig get].sendInfo boolValue]) + if ([[MPConfig get].sendInfo boolValue]) level = PearlLogLevelDebug; if (message.level >= level) @@ -333,7 +333,7 @@ NSString *userName = [[MPiOSAppDelegate get] activeUserForMainThread].name; PearlLogLevel logLevel = PearlLogLevelInfo; - if (logs && ([[MPiOSConfig get].sendInfo boolValue] || [[MPiOSConfig get].traceMode boolValue])) + if (logs && ([[MPConfig get].sendInfo boolValue] || [[MPiOSConfig get].traceMode boolValue])) logLevel = PearlLogLevelDebug; [[[PearlEMail alloc] initForEMailTo:@"Master Password Development " @@ -530,13 +530,13 @@ [PearlLogger get].historyLevel = [[MPiOSConfig get].traceMode boolValue]? PearlLogLevelTrace: PearlLogLevelInfo; // Send info - if ([[MPiOSConfig get].sendInfo boolValue]) { + if ([[MPConfig get].sendInfo boolValue]) { if ([PearlLogger get].printLevel > PearlLogLevelInfo) [PearlLogger get].printLevel = PearlLogLevelInfo; #ifdef CRASHLYTICS [[Crashlytics sharedInstance] setBoolValue:[[MPConfig get].rememberLogin boolValue] forKey:@"rememberLogin"]; - [[Crashlytics sharedInstance] setBoolValue:[[MPiOSConfig get].sendInfo boolValue] forKey:@"sendInfo"]; + [[Crashlytics sharedInstance] setBoolValue:[[MPConfig get].sendInfo boolValue] forKey:@"sendInfo"]; [[Crashlytics sharedInstance] setBoolValue:[[MPiOSConfig get].helpHidden boolValue] forKey:@"helpHidden"]; [[Crashlytics sharedInstance] setBoolValue:[[MPiOSConfig get].showSetup boolValue] forKey:@"showQuickStart"]; [[Crashlytics sharedInstance] setBoolValue:[[PearlConfig get].firstRun boolValue] forKey:@"firstRun"]; diff --git a/MasterPassword/ObjC/iOS/Storyboard.storyboard b/MasterPassword/ObjC/iOS/Storyboard.storyboard index 1a1aa4cd..120847c0 100644 --- a/MasterPassword/ObjC/iOS/Storyboard.storyboard +++ b/MasterPassword/ObjC/iOS/Storyboard.storyboard @@ -1,8 +1,8 @@ - + - - + + @@ -182,10 +182,10 @@ - + -