Skip to content
This repository was archived by the owner on Aug 2, 2023. It is now read-only.

Commit f12a02d

Browse files
committed
Merge branch 'release/4.0.3'
2 parents 678a513 + d574436 commit f12a02d

30 files changed

+1047
-16
lines changed

Classes/Telemetry/BITPersistence.m

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ - (void)createDirectoryStructureIfNeeded {
220220

221221
// Create telemetry subfolder
222222

223-
//NOTE: createDirectoryAtURL:withIntermediateDirectories:attributes:error
224-
//will return YES if the directory already exists and won't override anything.
225-
//No need to check if the directory already exists.
223+
// NOTE: createDirectoryAtURL:withIntermediateDirectories:attributes:error
224+
// will return YES if the directory already exists and won't override anything.
225+
// No need to check if the directory already exists.
226226
NSURL *telemetryURL = [appURL URLByAppendingPathComponent:kBITTelemetryDirectory];
227227
if (![fileManager createDirectoryAtURL:telemetryURL withIntermediateDirectories:YES attributes:nil error:&error]) {
228228
BITHockeyLog(@"%@", error.localizedDescription);
@@ -255,7 +255,8 @@ - (NSString *)nextURLOfType:(BITPersistenceType)type {
255255
includingPropertiesForKeys:@[NSURLNameKey]
256256
options:NSDirectoryEnumerationSkipsHiddenFiles
257257
error:&error];
258-
// each track method asks, if space is still available. Getting the file count for each event would be too expensive,
258+
259+
// Each track method asks if space is still available. Getting the file count for each event would be too expensive,
259260
// so let's get it here
260261
if (type == BITPersistenceTypeTelemetry) {
261262
_maxFileCountReached = fileNames.count >= _maxFileCount;
@@ -302,14 +303,24 @@ - (void)sendBundleSavedNotification {
302303

303304
- (NSString *)appHockeySDKDirectoryPath {
304305
if (!_appHockeySDKDirectoryPath) {
306+
307+
// Assemble the directory path we use to store our telemetry data in.
308+
// We use the current app's bundle identifier for the name of the subfolder within Application Support
309+
// as this is one of the few directories a sandboxed app can write to (Compare
310+
// https://developer.apple.com/library/mac/documentation/General/Conceptual/MOSXAppProgrammingGuide/AppRuntime/AppRuntime.html#//apple_ref/doc/uid/TP40010543-CH2-SW9 )
311+
// and then create our own subfolder within that.
305312
NSString *appSupportPath = [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] stringByStandardizingPath];
306-
NSString *bundleID = bit_mainBundleIdentifier();
313+
NSString *bundleID = [self bundleIdentifier];
314+
307315
if (appSupportPath && bundleID) {
308-
NSString *hockeySDKPath = [appSupportPath stringByAppendingPathComponent:kBITHockeyDirectory];
309-
_appHockeySDKDirectoryPath = [hockeySDKPath stringByAppendingPathComponent:bundleID];
316+
_appHockeySDKDirectoryPath = [[appSupportPath stringByAppendingPathComponent:bundleID] stringByAppendingPathComponent:kBITHockeyDirectory];
310317
}
311318
}
312319
return _appHockeySDKDirectoryPath;
313320
}
314321

322+
- (NSString *)bundleIdentifier {
323+
return bit_mainBundleIdentifier();
324+
}
325+
315326
@end

Classes/Telemetry/BITPersistencePrivate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,6 @@ FOUNDATION_EXPORT NSString *const BITPersistenceSuccessNotification;
141141
*/
142142
- (NSString *)fileURLForType:(BITPersistenceType)type;
143143

144+
- (NSString *)appHockeySDKDirectoryPath;
145+
144146
@end

HockeySDK-Mac.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'HockeySDK-Mac'
3-
s.version = '4.0.2'
3+
s.version = '4.0.3'
44

55
s.summary = 'Collect live crash reports, get feedback from your users, distribute your betas, and get usage data.'
66
s.description = <<-DESC

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[![Build Status](https://travis-ci.org/bitstadium/HockeySDK-iOS.svg?branch=develop)](https://travis-ci.org/bitstadium/HockeySDK-Mac)
22

3-
## Version 4.0.2
3+
## Version 4.0.3
44

5-
- [Changelog](http://www.hockeyapp.net/help/sdk/mac/4.0.2/docs/docs/Changelog.html)
5+
- [Changelog](http://www.hockeyapp.net/help/sdk/mac/4.0.3/docs/docs/Changelog.html)
66

77
**NOTE:** With the release of HockeySDK 4.0.0-alpha.1 a bug was introduced which lead to the exclusion of the Application Support folder from iCloud and iTunes backups.
88

@@ -359,7 +359,7 @@ To check if data is send properly to HockeyApp and also see some additional SDK
359359
<a id="documentation"></a>
360360
## 4. Documentation
361361

362-
Our documentation can be found on [HockeyApp](http://hockeyapp.net/help/sdk/mac/4.0.2/index.html).
362+
Our documentation can be found on [HockeyApp](http://hockeyapp.net/help/sdk/mac/4.0.3/index.html).
363363

364364
<a id="troubleshooting"></a>
365365
## 5.Troubleshooting

Support/BITPersistenceTests.m

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// BITPersistenceTests.m
3+
// HockeySDK
4+
//
5+
// Created by Patrick Dinger on 24/05/16.
6+
//
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import <OCMock/OCMock.h>
11+
#import "BITPersistence.h"
12+
#import "BITPersistencePrivate.h"
13+
14+
@interface BITPersistenceTests : XCTestCase
15+
16+
@end
17+
18+
@implementation BITPersistenceTests {
19+
BITPersistence *_subject;
20+
}
21+
22+
- (void)setUp {
23+
[super setUp];
24+
_subject = [BITPersistence alloc];
25+
id mock = OCMPartialMock(_subject);
26+
27+
OCMStub([mock bundleIdentifier]).andReturn(@"com.testapp");
28+
29+
_subject = [_subject init];
30+
}
31+
32+
- (void)tearDown {
33+
[super tearDown];
34+
}
35+
36+
- (void)testAppHockeySDKDirectoryPath {
37+
NSString *path = [_subject appHockeySDKDirectoryPath];
38+
39+
NSString *appSupportPath = [[NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES) lastObject] stringByStandardizingPath];
40+
NSString *validPath = [NSString stringWithFormat:@"%@/%@", appSupportPath, @"com.testapp/com.microsoft.HockeyApp"];
41+
42+
XCTAssertEqualObjects(path, validPath);
43+
}
44+
45+
@end

0 commit comments

Comments
 (0)