Skip to content
This repository was archived by the owner on Feb 19, 2020. It is now read-only.

Commit 90b2bfe

Browse files
committed
Merge branch 'hotfix/2.5.5'
2 parents f673a01 + cf32aa4 commit 90b2bfe

14 files changed

+219
-42
lines changed

Classes/BITCrashManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ typedef enum {
3636
BITCrashManagerStatusAlwaysAsk = 1,
3737
BITCrashManagerStatusAutoSend = 2
3838
} BITCrashManagerStatus;
39-
static NSString *kBITCrashManagerStatus = @"BITCrashManagerStatus";
39+
extern NSString *const kBITCrashManagerStatus;
4040

4141

4242
@protocol BITCrashManagerDelegate;

Classes/BITCrashManager.m

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#import <UIKit/UIKit.h>
3434
#import "HockeySDK.h"
3535
#import "HockeySDKPrivate.h"
36+
#import "BITHockeyHelper.h"
3637

3738
#import "BITCrashManagerPrivate.h"
3839
#import "BITCrashReportTextFormatter.h"
@@ -47,6 +48,8 @@
4748
#define kBITCrashMetaUserEmail @"BITCrashMetaUserEmail"
4849
#define kBITCrashMetaApplicationLog @"BITCrashMetaApplicationLog"
4950

51+
NSString *const kBITCrashManagerStatus = @"BITCrashManagerStatus";
52+
5053

5154
@interface BITCrashManager ()
5255

@@ -64,7 +67,6 @@ @implementation BITCrashManager
6467

6568
@synthesize fileManager = _fileManager;
6669

67-
6870
- (id)initWithAppIdentifier:(NSString *)appIdentifier {
6971
if ((self = [super init])) {
7072
_updateURL = BITHOCKEYSDK_URL;
@@ -275,6 +277,15 @@ - (void) handleCrashReport {
275277
if (crashData == nil) {
276278
BITHockeyLog(@"ERROR: Could not load crash report: %@", error);
277279
} else {
280+
// get the startup timestamp from the crash report, and the file timestamp to calculate the timeinterval when the crash happened after startup
281+
PLCrashReport *report = [[[PLCrashReport alloc] initWithData:crashData error:&error] autorelease];
282+
283+
if ([report.applicationInfo respondsToSelector:@selector(applicationStartupTimestamp)]) {
284+
if (report.systemInfo.timestamp && report.applicationInfo.applicationStartupTimestamp) {
285+
_timeintervalCrashInLastSessionOccured = [report.systemInfo.timestamp timeIntervalSinceDate:report.applicationInfo.applicationStartupTimestamp];
286+
}
287+
}
288+
278289
[crashData writeToFile:[_crashesDir stringByAppendingPathComponent: cacheFilename] atomically:YES];
279290

280291
// write the meta file
@@ -307,15 +318,6 @@ - (void) handleCrashReport {
307318
} else {
308319
BITHockeyLog(@"ERROR: Writing crash meta data failed. %@", error);
309320
}
310-
311-
// get the startup timestamp from the crash report, and the file timestamp to calculate the timeinterval when the crash happened after startup
312-
PLCrashReport *report = [[[PLCrashReport alloc] initWithData:crashData error:&error] autorelease];
313-
314-
if ([report.applicationInfo respondsToSelector:@selector(applicationStartupTimestamp)]) {
315-
if (report.systemInfo.timestamp && report.applicationInfo.applicationStartupTimestamp) {
316-
_timeintervalCrashInLastSessionOccured = [report.systemInfo.timestamp timeIntervalSinceDate:report.applicationInfo.applicationStartupTimestamp];
317-
}
318-
}
319321
}
320322
}
321323

@@ -365,8 +367,17 @@ - (BOOL)hasPendingCrashReport {
365367
if ([_crashFiles count] > 0) {
366368
BITHockeyLog(@"INFO: %i pending crash reports found.", [_crashFiles count]);
367369
return YES;
368-
} else
370+
} else {
371+
if (_didCrashInLastSession) {
372+
if (self.delegate != nil && [self.delegate respondsToSelector:@selector(crashManagerWillCancelSendingCrashReport:)]) {
373+
[self.delegate crashManagerWillCancelSendingCrashReport:self];
374+
}
375+
376+
_didCrashInLastSession = NO;
377+
}
378+
369379
return NO;
380+
}
370381
}
371382

372383

@@ -398,9 +409,7 @@ - (void)invokeDelayedProcessing {
398409
[self.delegate crashManagerWillShowSubmitCrashReportAlert:self];
399410
}
400411

401-
NSString *appName = [[[NSBundle mainBundle] localizedInfoDictionary] objectForKey:@"CFBundleDisplayName"];
402-
if (!appName)
403-
appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"] ?: BITHockeyLocalizedString(@"HockeyAppNamePlaceholder");
412+
NSString *appName = bit_appName(BITHockeyLocalizedString(@"HockeyAppNamePlaceholder"));
404413
NSString *alertDescription = [NSString stringWithFormat:BITHockeyLocalizedString(@"CrashDataFoundAnonymousDescription"), appName];
405414

406415
// the crash report is not anynomous any more if username or useremail are not nil
@@ -532,7 +541,8 @@ - (void)performSendingCrashReports {
532541
if ([report respondsToSelector:@selector(reportInfo)]) {
533542
crashUUID = report.reportInfo.reportGUID ?: @"";
534543
}
535-
NSString *crashLogString = [BITCrashReportTextFormatter stringValueForCrashReport:report];
544+
NSString *installString = bit_appAnonID() ?: @"";
545+
NSString *crashLogString = [BITCrashReportTextFormatter stringValueForCrashReport:report crashReporterKey:installString];
536546

537547
if ([report.applicationInfo.applicationVersion compare:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]] == NSOrderedSame) {
538548
_crashIdenticalCurrentVersion = YES;
@@ -569,7 +579,7 @@ - (void)performSendingCrashReports {
569579
description = [NSString stringWithFormat:@"%@", applicationLog];
570580
}
571581

572-
[crashes appendFormat:@"<crash><applicationname>%s</applicationname><uuids>%@</uuids><bundleidentifier>%@</bundleidentifier><systemversion>%@</systemversion><platform>%@</platform><senderversion>%@</senderversion><version>%@</version><uuid>%@</uuid><log><![CDATA[%@]]></log><userid>%@</userid><contact>%@</contact><description><![CDATA[%@]]></description></crash>",
582+
[crashes appendFormat:@"<crash><applicationname>%s</applicationname><uuids>%@</uuids><bundleidentifier>%@</bundleidentifier><systemversion>%@</systemversion><platform>%@</platform><senderversion>%@</senderversion><version>%@</version><uuid>%@</uuid><log><![CDATA[%@]]></log><username>%@</username><contact>%@</contact><installstring>%@</installstring><description><![CDATA[%@]]></description></crash>",
573583
[[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleExecutable"] UTF8String],
574584
[self extractAppUUIDs:report],
575585
report.applicationInfo.applicationIdentifier,
@@ -581,6 +591,7 @@ - (void)performSendingCrashReports {
581591
[crashLogString stringByReplacingOccurrencesOfString:@"]]>" withString:@"]]" @"]]><![CDATA[" @">" options:NSLiteralSearch range:NSMakeRange(0,crashLogString.length)],
582592
username,
583593
useremail,
594+
installString,
584595
[description stringByReplacingOccurrencesOfString:@"]]>" withString:@"]]" @"]]><![CDATA[" @">" options:NSLiteralSearch range:NSMakeRange(0,description.length)]];
585596

586597

Classes/BITCrashReportTextFormatter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
@interface BITCrashReportTextFormatter : NSObject {
4848
}
4949

50-
+ (NSString *)stringValueForCrashReport:(PLCrashReport *)report;
50+
+ (NSString *)stringValueForCrashReport:(PLCrashReport *)report crashReporterKey:(NSString *)crashReporterKey;
5151
+ (NSArray *)arrayOfAppUUIDsForCrashReport:(PLCrashReport *)report;
5252

5353
@end

Classes/BITCrashReportTextFormatter.m

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ @implementation BITCrashReportTextFormatter
7676
*
7777
* @return Returns the formatted result on success, or nil if an error occurs.
7878
*/
79-
+ (NSString *)stringValueForCrashReport:(PLCrashReport *)report {
79+
+ (NSString *)stringValueForCrashReport:(PLCrashReport *)report crashReporterKey:(NSString *)crashReporterKey {
8080
NSMutableString* text = [NSMutableString string];
8181
boolean_t lp64 = true; // quiesce GCC uninitialized value warning
8282

@@ -173,18 +173,22 @@ + (NSString *)stringValueForCrashReport:(PLCrashReport *)report {
173173
}
174174

175175
{
176-
NSString *reportGUID = @"[TODO]";
176+
NSString *reportGUID = @"TODO";
177177
if ([report respondsToSelector:@selector(reportInfo)]) {
178178
if (report.hasReportInfo && report.reportInfo.reportGUID != nil)
179179
reportGUID = report.reportInfo.reportGUID;
180180
}
181-
181+
182+
NSString *reporterKey = @"TODO";
183+
if (crashReporterKey && [crashReporterKey length] > 0)
184+
reporterKey = crashReporterKey;
185+
182186
NSString *hardwareModel = @"???";
183187
if (report.hasMachineInfo && report.machineInfo.modelName != nil)
184188
hardwareModel = report.machineInfo.modelName;
185189

186190
[text appendFormat: @"Incident Identifier: %@\n", reportGUID];
187-
[text appendFormat: @"CrashReporter Key: [TODO]\n"];
191+
[text appendFormat: @"CrashReporter Key: %@\n", reporterKey];
188192
[text appendFormat: @"Hardware Model: %@\n", hardwareModel];
189193
}
190194

@@ -240,8 +244,14 @@ + (NSString *)stringValueForCrashReport:(PLCrashReport *)report {
240244
NSString *osBuild = @"???";
241245
if (report.systemInfo.operatingSystemBuild != nil)
242246
osBuild = report.systemInfo.operatingSystemBuild;
243-
244-
[text appendFormat: @"Date/Time: %@\n", report.systemInfo.timestamp];
247+
248+
NSLocale *enUSPOSIXLocale = [[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"] autorelease];
249+
NSDateFormatter *rfc3339Formatter = [[[NSDateFormatter alloc] init] autorelease];
250+
[rfc3339Formatter setLocale:enUSPOSIXLocale];
251+
[rfc3339Formatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"];
252+
[rfc3339Formatter setTimeZone:[NSTimeZone timeZoneForSecondsFromGMT:0]];
253+
254+
[text appendFormat: @"Date/Time: %@\n", [rfc3339Formatter stringFromDate:report.systemInfo.timestamp]];
245255
[text appendFormat: @"OS Version: %@ %@ (%@)\n", osName, report.systemInfo.operatingSystemVersion, osBuild];
246256
[text appendFormat: @"Report Version: 104\n"];
247257
}

Classes/BITHockeyHelper.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
NSString *bit_URLEncodedString(NSString *inputString);
3434
NSString *bit_URLDecodedString(NSString *inputString);
3535
NSComparisonResult bit_versionCompare(NSString *stringA, NSString *stringB);
36+
NSString *bit_encodeAppIdentifier(NSString *inputString);
37+
NSString *bit_appName(NSString *placeHolderString);
38+
NSString *bit_appAnonID(void);
3639

3740
/* UIImage helpers */
3841
UIImage *bit_roundedCornerImage(UIImage *inputImage, NSInteger cornerSize, NSInteger borderSize);

Classes/BITHockeyHelper.m

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,44 @@ NSComparisonResult bit_versionCompare(NSString *stringA, NSString *stringB) {
7474
return result;
7575
}
7676

77+
NSString *bit_encodeAppIdentifier(NSString *inputString) {
78+
return (inputString ? bit_URLEncodedString(inputString) : bit_URLEncodedString([[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleIdentifier"]));
79+
}
80+
81+
NSString *bit_appName(NSString *placeHolderString) {
82+
NSString *appName = [[[NSBundle mainBundle] localizedInfoDictionary] objectForKey:@"CFBundleDisplayName"];
83+
if (!appName)
84+
appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"] ?: placeHolderString;
85+
86+
return appName;
87+
}
88+
89+
NSString *bit_appAnonID(void) {
90+
// try to new iOS6 identifierForAdvertising
91+
Class advertisingClass = NSClassFromString(@"ASIdentifierManager");
92+
if (advertisingClass) {
93+
id adInstance = [advertisingClass performSelector:NSSelectorFromString(@"sharedManager")];
94+
95+
SEL adidSelector = NSSelectorFromString(@"advertisingIdentifier");
96+
return [[adInstance performSelector:adidSelector] performSelector:NSSelectorFromString(@"UUIDString")];
97+
}
98+
99+
// try to new iOS6 identifierForVendor, in case ASIdentifierManager is not linked
100+
SEL vendoridSelector = NSSelectorFromString(@"identifierForVendor");
101+
if ([[UIDevice currentDevice] respondsToSelector:vendoridSelector]) {
102+
return [[[UIDevice currentDevice] performSelector:vendoridSelector] performSelector:NSSelectorFromString(@"UUIDString")];
103+
}
104+
105+
// use app bundle path
106+
NSArray *pathComponents = [[[NSBundle mainBundle] bundlePath] pathComponents];
107+
108+
if ([pathComponents count] > 1) {
109+
return [pathComponents objectAtIndex:(pathComponents.count - 2)];
110+
}
111+
112+
return nil;
113+
}
114+
77115

78116
#pragma mark UIImage private helpers
79117

Classes/BITHockeyManager.m

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,11 @@ - (id) init {
9797
_appStoreEnvironment = NO;
9898
_startManagerIsInvoked = NO;
9999

100-
// check if we are really not in an app store environment
101-
if ([[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]) {
102-
_appStoreEnvironment = NO;
103-
} else {
100+
#if !TARGET_IPHONE_SIMULATOR
101+
// check if we are really in an app store environment
102+
if (![[NSBundle mainBundle] pathForResource:@"embedded" ofType:@"mobileprovision"]) {
104103
_appStoreEnvironment = YES;
105104
}
106-
107-
#if TARGET_IPHONE_SIMULATOR
108-
_appStoreEnvironment = NO;
109105
#endif
110106

111107
[self performSelector:@selector(validateStartManagerIsInvoked) withObject:nil afterDelay:0.0f];

Classes/BITUpdateManager.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,10 @@ - (void)showUpdateView {
483483
if (NSClassFromString(@"TTNavigator")) {
484484
#pragma clang diagnostic push
485485
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
486-
parentViewController = [[NSClassFromString(@"TTNavigator") performSelector:(NSSelectorFromString(@"navigator"))] visibleViewController];
486+
UIViewController *ttParentViewController = nil;
487+
ttParentViewController = [[NSClassFromString(@"TTNavigator") performSelector:(NSSelectorFromString(@"navigator"))] visibleViewController];
488+
if (ttParentViewController)
489+
parentViewController = ttParentViewController;
487490
#pragma clang diagnostic pop
488491
}
489492

Classes/HockeySDK.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ typedef enum {
5252
BITCrashAPIReceivedEmptyResponse,
5353
BITCrashAPIErrorWithStatusCode
5454
} BITCrashErrorReason;
55-
static NSString *kBITCrashErrorDomain = @"BITCrashReporterErrorDomain";
56-
55+
extern NSString *const kBITCrashErrorDomain;
5756

5857
// Update App Versions
5958

@@ -66,7 +65,7 @@ typedef enum {
6665
BITUpdateAPIClientAuthorizationMissingSecret,
6766
BITUpdateAPIClientCannotCreateConnection
6867
} BITUpdateErrorReason;
69-
static NSString *kBITUpdateErrorDomain = @"BITUpdaterErrorDomain";
68+
extern NSString *const kBITUpdateErrorDomain;
7069

7170

7271
#endif

Classes/HockeySDKPrivate.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#import "HockeySDKPrivate.h"
3131
#include <CommonCrypto/CommonDigest.h>
3232

33+
NSString *const kBITCrashErrorDomain = @"BITCrashReporterErrorDomain";
34+
NSString *const kBITUpdateErrorDomain = @"BITUpdaterErrorDomain";
3335

3436
// Load the framework bundle.
3537
NSBundle *BITHockeyBundle(void) {
@@ -66,4 +68,4 @@
6668
result[12], result[13],
6769
result[14], result[15]
6870
];
69-
}
71+
}

HockeySDK.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
Pod::Spec.new do |s|
22
s.name = 'HockeySDK'
3-
s.version = '2.5.3'
3+
s.version = '2.5.5'
44
s.license = 'MIT'
55
s.platform = :ios, '4.0'
66
s.summary = 'Distribute beta apps and collect crash reports with HockeyApp.'
77
s.homepage = 'http://hockeyapp.net/'
88
s.author = { 'Andreas Linde' => '[email protected]', 'Thomas Dohmke' => "[email protected]" }
9-
s.source = { :git => 'https://github.com/bitstadium/HockeySDK-iOS.git', :tag => '2.5.3' }
9+
s.source = { :git => 'https://github.com/bitstadium/HockeySDK-iOS.git', :tag => '2.5.5' }
1010

1111
s.description = 'HockeyApp is a server to distribute beta apps and collect crash reports. ' \
1212
'It improves the testing process dramatically and can be used for both beta ' \

Support/buildnumber.xcconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
BUILD_NUMBER = 9
2-
VERSION_STRING = 2.5.4
3-
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) BITHOCKEY_VERSION="@\"2.5.4\""
1+
BUILD_NUMBER = 10
2+
VERSION_STRING = 2.5.5
3+
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) BITHOCKEY_VERSION="@\"2.5.5\""

docs/Changelog-template.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
### Version 2.5.5
2+
3+
- General:
4+
5+
- [BUGFIX] Fix some new compiler warnings
6+
7+
- Crash Reporting:
8+
9+
- [NEW] Add anonymous device ID to crash reports
10+
- [BUGFIX] Move calculation of time interval between startup and crash further up in the code, so delegates can use this information e.g. to add it into a log file
11+
- [BUGFIX] Call delegate also if a crash was detected but could not be read (if handling crashes on startup is implemented)
12+
- [BUGFIX] Format timestamp in crash report to be always UTC in en_US locale
13+
- [BUGFIX] Make sure crash reports incident identifier and key don't have special [] chars and some value
14+
15+
- Updating:
16+
17+
- [BUGFIX] Fix a problem showing the update UI animated if there TTNavigator class is present even though not being used
18+
119
### Version 2.5.4
220

321
- General:

0 commit comments

Comments
 (0)