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

Commit ababf15

Browse files
author
Benjamin Scholtysik (Reimold)
authored
Merge pull request #433 from bitstadium/release/4.1.6
Release/4.1.6
2 parents ddda084 + d0f2a87 commit ababf15

30 files changed

+248
-821
lines changed

.travis.yml

+12-12
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,38 @@ env:
1010
matrix:
1111
- SCHEME="HockeySDK" DESTINATION="OS=8.1,name=iPad Air" RUN_TESTS="YES"
1212
- SCHEME="HockeySDK" DESTINATION="OS=8.2,name=iPhone 6 Plus" RUN_TESTS="YES"
13-
- SCHEME="HockeySDK" DESTINATION="OS=8.3,name=iPad 2" RUN_TESTS="YES"
13+
- SCHEME="HockeySDK" DESTINATION="OS=8.3,name=iPad 2" RUN_TESTS="YES"
1414
- SCHEME="HockeySDK" DESTINATION="OS=8.4,name=iPhone 4s" RUN_TESTS="YES"
1515
- SCHEME="HockeySDK" DESTINATION="OS=9.0,name=iPad Air" RUN_TESTS="YES"
1616
- SCHEME="HockeySDK" DESTINATION="OS=9.1,name=iPhone 6 Plus" RUN_TESTS="YES"
17-
- SCHEME="HockeySDK" DESTINATION="OS=10.2,name=iPad Pro (9.7-inch)" RUN_TESTS="YES"
18-
- SCHEME="HockeySDK" DESTINATION="OS=10.3,name=iPhone 6s" RUN_TESTS="YES"
19-
- SCHEME="HockeySDK Framework" DESTINATION="platform=iOS Simulator,OS=10.3,name=iPhone 6" RUN_TESTS="YES"
17+
- SCHEME="HockeySDK" DESTINATION="OS=10.2,name=iPad Pro (9.7-inch)" RUN_TESTS="YES"
18+
- SCHEME="HockeySDK" DESTINATION="OS=10.3.1,name=iPhone 6s" RUN_TESTS="YES"
19+
- SCHEME="HockeySDK Framework" DESTINATION="platform=iOS Simulator,OS=10.3.1,name=iPhone 6" RUN_TESTS="YES"
2020
- SCHEME="HockeySDK Distribution" RUN_TESTS="NO" LINT="YES"
2121

2222
before_install:
2323
- xcrun simctl list
2424
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
2525
- gem install xcpretty-travis-formatter --no-rdoc --no-ri --no-document --quiet
2626
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
27-
- brew unlink carthage
2827
- brew install carthage
2928

3029
script:
3130
- open -b com.apple.iphonesimulator
3231
- set -o pipefail
3332
- COMMAND="env NSUnbufferedIO=YES xcodebuild -project '$PROJECT' -scheme '$SCHEME' -sdk '$SDK' -configuration '$CONFIGURATION'"
3433

34+
# Add xcpretty
35+
- COMMAND_SUFFIX=" | tee xcodebuild.log | xcpretty -f `xcpretty-travis-formatter`"
36+
3537
# Run tests
3638
- if [ $RUN_TESTS == "YES" ]; then
37-
COMMAND+=" -destination '$DESTINATION' XCODEBUILD_GCC_PREPROCESSOR_DEFINITIONS="CI=1" clean test";
39+
COMMAND+=" -destination '$DESTINATION' XCODEBUILD_GCC_PREPROCESSOR_DEFINITIONS=\"CI=1\" "
40+
COMMAND="$COMMAND clean build-for-testing $COMMAND_SUFFIX && travis_retry $COMMAND test-without-building $COMMAND_SUFFIX";
41+
else
42+
COMMAND+="$COMMAND_SUFFIX";
3843
fi
3944

40-
- COMMAND+=" | tee xcodebuild.log"
41-
42-
# Add xcpretty
43-
- COMMAND+=" | xcpretty -f `xcpretty-travis-formatter`"
44-
4545
- echo $COMMAND
4646
- eval $COMMAND && rm xcodebuild.log
4747
- if [ $LINT == "YES" ]; then
@@ -55,4 +55,4 @@ after_failure:
5555
- cat xcodebuild.log
5656
- cat -n $TMPDIR/com.apple.dt.XCTest-status/Session*.log
5757
- cat -n ~/Library/Logs/DiagnosticReports/xctest*.crash
58-
- sleep 5
58+
- sleep 5

Classes/BITChannel.m

+47-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727

2828
NS_ASSUME_NONNULL_BEGIN
2929

30-
@implementation BITChannel
30+
@implementation BITChannel {
31+
id _appDidEnterBackgroundObserver;
32+
}
3133

3234
@synthesize persistence = _persistence;
3335
@synthesize channelBlocked = _channelBlocked;
@@ -47,6 +49,8 @@ - (instancetype)init {
4749
}
4850
dispatch_queue_t serialQueue = dispatch_queue_create(BITDataItemsOperationsQueue, DISPATCH_QUEUE_SERIAL);
4951
_dataItemsOperations = serialQueue;
52+
53+
[self registerObservers];
5054
}
5155
return self;
5256
}
@@ -59,6 +63,48 @@ - (instancetype)initWithTelemetryContext:(BITTelemetryContext *)telemetryContext
5963
return self;
6064
}
6165

66+
- (void)dealloc {
67+
[self unregisterObservers];
68+
[self invalidateTimer];
69+
}
70+
71+
#pragma mark - Observers
72+
73+
- (void) registerObservers {
74+
__weak typeof(self) weakSelf = self;
75+
if(nil == _appDidEnterBackgroundObserver) {
76+
void (^notificationBlock)(NSNotification *note) = ^(NSNotification *note) {
77+
typeof(self) strongSelf = weakSelf;
78+
if ([strongSelf timerIsRunning]) {
79+
[strongSelf persistDataItemQueue];
80+
81+
/**
82+
* From the documentation for applicationDidEnterBackground:
83+
* It's likely any background tasks you start in applicationDidEnterBackground: will not run until after that method exits,
84+
* you should request additional background execution time before starting those tasks. In other words,
85+
* first call beginBackgroundTaskWithExpirationHandler: and then run the task on a dispatch queue or secondary thread.
86+
*/
87+
UIApplication *sharedApplication = [UIApplication sharedApplication];
88+
__block UIBackgroundTaskIdentifier _backgroundTask = [sharedApplication beginBackgroundTaskWithExpirationHandler:^{
89+
[sharedApplication endBackgroundTask:_backgroundTask];
90+
_backgroundTask = UIBackgroundTaskInvalid;
91+
}];
92+
}
93+
};
94+
_appDidEnterBackgroundObserver = [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidEnterBackgroundNotification
95+
object:nil
96+
queue:NSOperationQueue.mainQueue
97+
usingBlock:notificationBlock];
98+
}
99+
}
100+
101+
- (void) unregisterObservers {
102+
if(_appDidEnterBackgroundObserver) {
103+
[[NSNotificationCenter defaultCenter] removeObserver:_appDidEnterBackgroundObserver];
104+
_appDidEnterBackgroundObserver = nil;
105+
}
106+
}
107+
62108
#pragma mark - Queue management
63109

64110
- (BOOL)isQueueBusy {

Classes/BITCrashCXXExceptionHandler.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
@implementation BITCrashUncaughtCXXExceptionHandlerManager
6060

61-
extern "C" void LIBCXXABI_NORETURN __cxa_throw(void *exception_object, std::type_info *tinfo, void (*dest)(void *))
61+
extern "C" void __attribute__((noreturn)) __cxa_throw(void *exception_object, std::type_info *tinfo, void (*dest)(void *))
6262
{
6363
// Purposely do not take a lock in this function. The aim is to be as fast as
6464
// possible. While we could really use some of the info set up by the real
@@ -72,7 +72,7 @@ @implementation BITCrashUncaughtCXXExceptionHandlerManager
7272
// implementation changing in a future version. (Or not existing in an earlier
7373
// version).
7474

75-
typedef void (*cxa_throw_func)(void *, std::type_info *, void (*)(void *)) LIBCXXABI_NORETURN;
75+
typedef void (*cxa_throw_func)(void *, std::type_info *, void (*)(void *)) __attribute__((noreturn));
7676
static dispatch_once_t predicate = 0;
7777
static cxa_throw_func __original__cxa_throw = nullptr;
7878
static const void **__real_objc_ehtype_vtable = nullptr;

Classes/BITCrashManager.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737

3838

3939
/**
40-
* Custom block that handles the alert that prompts the user whether he wants to send crash reports
40+
* Custom block that handles the alert that prompts the user whether they want to send crash reports
4141
*/
42-
typedef void(^BITCustomAlertViewHandler)();
42+
typedef void(^BITCustomAlertViewHandler)(void);
4343

4444

4545
/**
@@ -340,7 +340,7 @@ typedef NS_ENUM(NSUInteger, BITCrashManagerUserInput) {
340340

341341
/**
342342
Lets you set a custom block which handles showing a custom UI and asking the user
343-
whether he wants to send the crash report.
343+
whether they want to send the crash report.
344344
345345
This replaces the default alert the SDK would show!
346346
@@ -350,7 +350,7 @@ typedef NS_ENUM(NSUInteger, BITCrashManagerUserInput) {
350350
In addition to this you should always ask your users if they agree to send crash reports, send them
351351
always or not and return the result when calling `handleUserInput:withUserProvidedCrashDescription`.
352352
353-
@param alertViewHandler A block that is responsible for loading, presenting and and dismissing your custom user interface which prompts the user if he wants to send crash reports. The block is also responsible for triggering further processing of the crash reports.
353+
@param alertViewHandler A block that is responsible for loading, presenting and and dismissing your custom user interface which prompts the user if they want to send crash reports. The block is also responsible for triggering further processing of the crash reports.
354354
355355
@warning This is not available when compiled for Watch OS!
356356

Classes/BITCrashManager.m

+8-26
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ - (void)invokeDelayedProcessing {
10421042
// If the top level error handler differs from our own, then at least another one was added.
10431043
// This could cause exception crashes not to be reported to HockeyApp. See log message for details.
10441044
if (self.exceptionHandler != currentHandler) {
1045-
BITHockeyLogWarning(@"[HockeySDK] WARNING: Another exception handler was added. If this invokes any kind exit() after processing the exception, which causes any subsequent error handler not to be invoked, these crashes will NOT be reported to HockeyApp!");
1045+
BITHockeyLogWarning(@"[HockeySDK] WARNING: Another exception handler was added. If this invokes any kind of exit() after processing the exception, which causes any subsequent error handler not to be invoked, these crashes will NOT be reported to HockeyApp!");
10461046
}
10471047
}
10481048

@@ -1154,18 +1154,10 @@ - (void)invokeDelayedProcessing {
11541154
}
11551155
}
11561156

1157-
- (void)startManagerInXamarinEnvironment {
1158-
[self startManagerInSdkEnvironment:BITSdkEnvironmentXamarin];
1159-
}
1160-
1161-
- (void)startManager {
1162-
[self startManagerInSdkEnvironment:BITSdkEnvironmentNative];
1163-
}
1164-
11651157
/**
11661158
* Main startup sequence initializing PLCrashReporter if it wasn't disabled
11671159
*/
1168-
- (void)startManagerInSdkEnvironment:(BITSdkEnvironment)sdkEnvironment {
1160+
- (void)startManager {
11691161
if (_crashManagerStatus == BITCrashManagerStatusDisabled) return;
11701162

11711163
[self registerObservers];
@@ -1187,21 +1179,8 @@ - (void)startManagerInSdkEnvironment:(BITSdkEnvironment)sdkEnvironment {
11871179
symbolicationStrategy = PLCrashReporterSymbolicationStrategyAll;
11881180
}
11891181

1190-
BITPLCrashReporterConfig *config;
1191-
1192-
switch (sdkEnvironment) {
1193-
case BITSdkEnvironmentXamarin:
1194-
config = [[BITPLCrashReporterConfig alloc] initWithSignalHandlerType: signalHandlerType
1195-
symbolicationStrategy: symbolicationStrategy
1196-
shouldRegisterUncaughtExceptionHandler:NO];
1197-
1198-
break;
1199-
default:
1200-
config = [[BITPLCrashReporterConfig alloc] initWithSignalHandlerType: signalHandlerType
1201-
symbolicationStrategy: symbolicationStrategy];
1202-
break;
1203-
}
1204-
1182+
BITPLCrashReporterConfig *config = [[BITPLCrashReporterConfig alloc] initWithSignalHandlerType: signalHandlerType
1183+
symbolicationStrategy: symbolicationStrategy];
12051184
self.plCrashReporter = [[BITPLCrashReporter alloc] initWithConfiguration: config];
12061185

12071186
// Check if we previously crashed
@@ -1261,8 +1240,11 @@ - (void)startManagerInSdkEnvironment:(BITSdkEnvironment)sdkEnvironment {
12611240

12621241
BITHockeyLogDebug(@"INFO: Exception handler successfully initialized.");
12631242
} else {
1264-
// this should never happen, theoretically only if NSSetUncaugtExceptionHandler() has some internal issues
1243+
1244+
// If we're running in a Xamarin Environment, the exception handler will be the one by the xamarin runtime, not ours.
1245+
// In other cases, this should never happen, theoretically only if NSSetUncaugtExceptionHandler() has some internal issues
12651246
BITHockeyLogError(@"[HockeySDK] ERROR: Exception handler could not be set. Make sure there is no other exception handler set up!");
1247+
BITHockeyLogError(@"[HockeySDK] ERROR: If you are using the HockeySDK-Xamarin, this is expected behavior and you can ignore this message");
12661248
}
12671249

12681250
// Add the C++ uncaught exception handler, which is currently not handled by PLCrashReporter internally

Classes/BITCrashManagerPrivate.h

-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@
8585

8686
- (instancetype)initWithAppIdentifier:(NSString *)appIdentifier appEnvironment:(BITEnvironment)environment hockeyAppClient:(BITHockeyAppClient *)hockeyAppClient NS_DESIGNATED_INITIALIZER;
8787

88-
- (void)startManagerInXamarinEnvironment;
89-
9088
- (void)cleanCrashReports;
9189

9290
- (NSString *)userIDForCrashReport;

Classes/BITFeedbackListViewController.m

+11
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
517517
cell.textLabel.textAlignment = NSTextAlignmentCenter;
518518
}
519519

520+
cell.textLabel.accessibilityTraits = UIAccessibilityTraitStaticText;
520521
cell.textLabel.text = [NSString stringWithFormat:BITHockeyLocalizedString(@"HockeyFeedbackListLastUpdated"),
521522
[self.manager lastCheck] ? [self.lastUpdateDateFormatter stringFromDate:[self.manager lastCheck]] : BITHockeyLocalizedString(@"HockeyFeedbackListNeverUpdated")];
522523

@@ -545,6 +546,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
545546
cell.selectionStyle = UITableViewCellSelectionStyleGray;
546547
}
547548

549+
// Set accessibilityTraits to UIAccessibilityTraitNone to make sure we're not setting the trait to an incorrect type for recycled cells.
550+
cell.textLabel.accessibilityTraits = UIAccessibilityTraitNone;
551+
548552
// button
549553
NSString *titleString = nil;
550554

@@ -554,6 +558,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
554558
}
555559

556560
if (indexPath.section == 0) {
561+
cell.textLabel.accessibilityTraits = UIAccessibilityTraitButton;
557562
if ([self.manager numberOfMessages] == 0) {
558563
titleString = BITHockeyLocalizedString(@"HockeyFeedbackListButtonWriteFeedback");
559564
} else {
@@ -563,17 +568,22 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
563568
if ([self.manager requireUserName] == BITFeedbackUserDataElementRequired ||
564569
([self.manager requireUserName] == BITFeedbackUserDataElementOptional && [self.manager userName] != nil)
565570
) {
571+
cell.textLabel.accessibilityTraits = UIAccessibilityTraitStaticText;
566572
titleString = [NSString stringWithFormat:BITHockeyLocalizedString(@"HockeyFeedbackListButtonUserDataWithName"), [self.manager userName] ?: @"-"];
567573
} else if ([self.manager requireUserEmail] == BITFeedbackUserDataElementRequired ||
568574
([self.manager requireUserEmail] == BITFeedbackUserDataElementOptional && [self.manager userEmail] != nil)
569575
) {
576+
cell.textLabel.accessibilityTraits = UIAccessibilityTraitStaticText;
570577
titleString = [NSString stringWithFormat:BITHockeyLocalizedString(@"HockeyFeedbackListButtonUserDataWithEmail"), [self.manager userEmail] ?: @"-"];
571578
} else if ([self.manager requireUserName] == BITFeedbackUserDataElementOptional) {
579+
cell.textLabel.accessibilityTraits = UIAccessibilityTraitButton;
572580
titleString = BITHockeyLocalizedString(@"HockeyFeedbackListButtonUserDataSetName");
573581
} else {
582+
cell.textLabel.accessibilityTraits = UIAccessibilityTraitButton;
574583
titleString = BITHockeyLocalizedString(@"HockeyFeedbackListButtonUserDataSetEmail");
575584
}
576585
} else {
586+
cell.textLabel.accessibilityTraits = UIAccessibilityTraitButton;
577587
titleString = BITHockeyLocalizedString(@"HockeyFeedbackListButtonDeleteAllMessages");
578588
titleColor = BIT_RGBCOLOR(251, 35, 35);
579589
}
@@ -652,6 +662,7 @@ - (void)handleResponseForAttachment:(BITFeedbackMessageAttachment *)attachment r
652662
[attachment replaceData:responseData];
653663
[[NSNotificationCenter defaultCenter] postNotificationName:kBITFeedbackUpdateAttachmentThumbnail object:attachment];
654664
[[BITHockeyManager sharedHockeyManager].feedbackManager saveMessages];
665+
[self.tableView reloadData];
655666
});
656667
}
657668
}

Classes/BITFeedbackManager.m

+2-1
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ - (void)updateMessageListFromResponse:(NSDictionary *)jsonDictionary {
780780
int attachmentIndex = 0;
781781
for (BITFeedbackMessageAttachment *attachment in matchingSendInProgressOrInConflictMessage.attachments) {
782782
attachment.identifier = feedbackAttachments[attachmentIndex][@"id"];
783+
attachment.sourceURL = feedbackAttachments[attachmentIndex][@"url"];
783784
attachmentIndex++;
784785
}
785786
}
@@ -822,7 +823,7 @@ - (void)updateMessageListFromResponse:(NSDictionary *)jsonDictionary {
822823

823824
// we got a new incoming message, trigger user notification system
824825
if (newMessage) {
825-
// check if the latest message is from the users own email address, then don't show an alert since he answered using his own email
826+
// check if the latest message is from the users own email address, then don't show an alert since they answered using their own email
826827
BOOL latestMessageFromUser = NO;
827828

828829
BITFeedbackMessage *latestMessage = [self lastMessageHavingID];

Classes/BITFeedbackMessageAttachment.m

+7
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,13 @@ - (UIImage *)thumbnailWithSize:(CGSize)size {
209209

210210
#pragma mark - Persistence Helpers
211211

212+
- (void)setFilename:(NSString *)filename {
213+
if (filename) {
214+
filename = [_cachePath stringByAppendingPathComponent:[filename lastPathComponent]];
215+
}
216+
_filename = filename;
217+
}
218+
212219
- (NSString *)possibleFilename {
213220
if (_tempFilename) {
214221
return _tempFilename;

Classes/BITHockeyManager.h

-13
Original file line numberDiff line numberDiff line change
@@ -191,19 +191,6 @@ NS_ASSUME_NONNULL_BEGIN
191191
*/
192192
- (void)startManager;
193193

194-
/**
195-
Starts the manager and runs all modules from a Xamarin environment. This is intended to be used by the HockeySDK-Xamarin.
196-
We now need to make a difference as BITCrashManager needs to setup PLCrashReporter differently for Xamarin apps.
197-
198-
@warning Do not use this API from within a native iOS app.
199-
200-
Call this after configuring the manager and setting up all modules.
201-
202-
@see configureWithIdentifier:delegate:
203-
@see configureWithBetaIdentifier:liveIdentifier:delegate:
204-
*/
205-
- (void)startManagerInXamarinEnvironment;
206-
207194
#pragma mark - Public Properties
208195

209196
///-----------------------------------------------------------------------------

Classes/BITHockeyManager.m

+1-18
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,6 @@ - (void)configureWithBetaIdentifier:(NSString *)betaIdentifier liveIdentifier:(N
220220
}
221221

222222
- (void)startManager {
223-
[self startManagerWithEnvironment:BITSdkEnvironmentNative];
224-
}
225-
226-
- (void)startManagerInXamarinEnvironment {
227-
[self startManagerWithEnvironment:BITSdkEnvironmentXamarin];
228-
BITHockeyLogVerbose(@"Started the BITHockeyManager with Xamarin Environment.");
229-
}
230-
231-
- (void)startManagerWithEnvironment:(BITSdkEnvironment)sdkEnvironment {
232223
if (!_validAppIdentifier) return;
233224
if (_startManagerIsInvoked) {
234225
BITHockeyLogWarning(@"[HockeySDK] Warning: startManager should only be invoked once! This call is ignored.");
@@ -262,15 +253,7 @@ - (void)startManagerWithEnvironment:(BITSdkEnvironment)sdkEnvironment {
262253
}
263254
#endif
264255

265-
// Start BITCrashManager with the environment flag to make sure we don't break NSException reporting for Xamarin.
266-
switch (sdkEnvironment) {
267-
case BITSdkEnvironmentXamarin:
268-
[_crashManager startManagerInXamarinEnvironment];
269-
break;
270-
default:
271-
[_crashManager startManager];
272-
break;
273-
}
256+
[_crashManager startManager];
274257
}
275258
#endif /* HOCKEYSDK_FEATURE_CRASH_REPORTER */
276259

0 commit comments

Comments
 (0)