Skip to content

Commit ec7431c

Browse files
committed
Merge pull request #24 from adeven/development
Check availability of NSURLIsExcludedFromBackupKey
2 parents 2ea996b + 25434af commit ec7431c

File tree

5 files changed

+39
-15
lines changed

5 files changed

+39
-15
lines changed

AdjustIO.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Pod::Spec.new do |s|
22
s.name = "AdjustIO"
3-
s.version = "2.1.2"
3+
s.version = "2.1.3"
44
s.summary = "This is the iOS SDK of AdjustIo. You can read more about it at http://adjust.io."
55
s.homepage = "http://adjust.io"
66
s.license = { :type => 'MIT', :file => 'MIT-LICENSE' }
77
s.author = { "Christian Wellenbrock" => "[email protected]" }
8-
s.source = { :git => "https://github.com/adeven/adjust_ios_sdk.git", :tag => "v2.1.2" }
8+
s.source = { :git => "https://github.com/adeven/adjust_ios_sdk.git", :tag => "v2.1.3" }
99
s.platform = :ios, '4.3'
1010
s.framework = 'AdSupport', 'SystemConfiguration'
1111
s.source_files = 'AdjustIo/*.{h,m}', 'AdjustIo/AIAdditions/*.{h,m}'

AdjustIo/AIUtil.m

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010
#import "AILogger.h"
1111
#import "UIDevice+AIAdditions.h"
1212

13+
#include <sys/xattr.h>
14+
1315
static NSString * const kBaseUrl = @"https://app.adjust.io";
14-
static NSString * const kClientSdk = @"ios2.1.2";
16+
static NSString * const kClientSdk = @"ios2.1.3";
1517

1618

1719
#pragma mark -
@@ -72,15 +74,37 @@ + (NSString *)sanitize:(NSString *)string defaultString:(NSString *)defaultStrin
7274
return result;
7375
}
7476

77+
// inspired by https://gist.github.com/kevinbarrett/2002382
7578
+ (void)excludeFromBackup:(NSString *)path {
7679
NSURL *url = [NSURL fileURLWithPath:path];
77-
NSError *error = nil;
78-
BOOL success = [url setResourceValue:[NSNumber numberWithBool:YES]
79-
forKey:NSURLIsExcludedFromBackupKey
80-
error:&error];
81-
82-
if (!success) {
83-
[AILogger debug:@"Failed to exclude '%@' from backup (%@)", url.lastPathComponent, error.localizedDescription];
80+
const char* filePath = [[url path] fileSystemRepresentation];
81+
const char* attrName = "com.apple.MobileBackup";
82+
83+
if (&NSURLIsExcludedFromBackupKey == nil) { // iOS 5.0.1 and lower
84+
u_int8_t attrValue = 1;
85+
int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
86+
if (result != 0) {
87+
[AILogger debug:@"Failed to exclude '%@' from backup", url.lastPathComponent];
88+
}
89+
} else { // iOS 5.0 and higher
90+
// First try and remove the extended attribute if it is present
91+
int result = getxattr(filePath, attrName, NULL, sizeof(u_int8_t), 0, 0);
92+
if (result != -1) {
93+
// The attribute exists, we need to remove it
94+
int removeResult = removexattr(filePath, attrName, 0);
95+
if (removeResult == 0) {
96+
[AILogger debug:@"Removed extended attribute on file '%@'", url];
97+
}
98+
}
99+
100+
// Set the new key
101+
NSError *error = nil;
102+
BOOL success = [url setResourceValue:[NSNumber numberWithBool:YES]
103+
forKey:NSURLIsExcludedFromBackupKey
104+
error:&error];
105+
if (!success) {
106+
[AILogger debug:@"Failed to exclude '%@' from backup (%@)", url.lastPathComponent, error.localizedDescription];
107+
}
84108
}
85109
}
86110

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ If you're using [CocoaPods][cocoapods], you can add the following line to your
1313
`Podfile` and continue with [step 3](#step3):
1414

1515
```ruby
16-
pod 'AdjustIO', :git => 'git://github.com/adeven/adjust_ios_sdk.git', :tag => 'v2.1.2'
16+
pod 'AdjustIO', :git => 'git://github.com/adeven/adjust_ios_sdk.git', :tag => 'v2.1.3'
1717
```
1818

1919
### 1. Get the SDK

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.2
1+
2.1.3

doc/migration.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
## Migrate your AdjustIo SDK for iOS from v1.x to v2.1.2
1+
## Migrate your AdjustIo SDK for iOS from v1.x to v2.1.3
22

33
1. Delete the old `AdjustIo` source folder from your Xcode project. Download
4-
version v2.1.2 and drag the new folder into your Xcode project.
4+
version v2.1.3 and drag the new folder into your Xcode project.
55

66
![][drag]
77

@@ -55,7 +55,7 @@
5555
2. The `appDidLaunch` method now expects your App Token instead of your App ID.
5656
You can find your App Token in your [dashboard].
5757

58-
2. The AdjustIo SDK for iOS 2.1.2 uses [ARC][arc]. If you haven't done already,
58+
2. The AdjustIo SDK for iOS 2.1.3 uses [ARC][arc]. If you haven't done already,
5959
we recommend [transitioning your project to use ARC][transition] as well. If
6060
you don't want to use ARC, you have to enable ARC for all files of the
6161
AdjustIo SDK. Please consult the [README] for details.

0 commit comments

Comments
 (0)