From 1b498b339d0ee50cd0680912b4e4e11c42cc4a24 Mon Sep 17 00:00:00 2001 From: Christian Wellenbrock Date: Mon, 13 Jan 2014 14:08:11 +0100 Subject: [PATCH 1/2] Check availability of NSURLIsExcludedFromBackupKey to avoid crashes on iOS 5.0.1 and lower --- AdjustIo/AIUtil.m | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/AdjustIo/AIUtil.m b/AdjustIo/AIUtil.m index a216268fa..a298018f4 100644 --- a/AdjustIo/AIUtil.m +++ b/AdjustIo/AIUtil.m @@ -10,6 +10,8 @@ #import "AILogger.h" #import "UIDevice+AIAdditions.h" +#include + static NSString * const kBaseUrl = @"https://app.adjust.io"; static NSString * const kClientSdk = @"ios2.1.2"; @@ -72,15 +74,37 @@ + (NSString *)sanitize:(NSString *)string defaultString:(NSString *)defaultStrin return result; } +// inspired by https://gist.github.com/kevinbarrett/2002382 + (void)excludeFromBackup:(NSString *)path { NSURL *url = [NSURL fileURLWithPath:path]; - NSError *error = nil; - BOOL success = [url setResourceValue:[NSNumber numberWithBool:YES] - forKey:NSURLIsExcludedFromBackupKey - error:&error]; - - if (!success) { - [AILogger debug:@"Failed to exclude '%@' from backup (%@)", url.lastPathComponent, error.localizedDescription]; + const char* filePath = [[url path] fileSystemRepresentation]; + const char* attrName = "com.apple.MobileBackup"; + + if (&NSURLIsExcludedFromBackupKey == nil) { // iOS 5.0.1 and lower + u_int8_t attrValue = 1; + int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0); + if (result != 0) { + [AILogger debug:@"Failed to exclude '%@' from backup", url.lastPathComponent]; + } + } else { // iOS 5.0 and higher + // First try and remove the extended attribute if it is present + int result = getxattr(filePath, attrName, NULL, sizeof(u_int8_t), 0, 0); + if (result != -1) { + // The attribute exists, we need to remove it + int removeResult = removexattr(filePath, attrName, 0); + if (removeResult == 0) { + [AILogger debug:@"Removed extended attribute on file '%@'", url]; + } + } + + // Set the new key + NSError *error = nil; + BOOL success = [url setResourceValue:[NSNumber numberWithBool:YES] + forKey:NSURLIsExcludedFromBackupKey + error:&error]; + if (!success) { + [AILogger debug:@"Failed to exclude '%@' from backup (%@)", url.lastPathComponent, error.localizedDescription]; + } } } From d3b36eaf9226cc443a7fd841253f2367da3ab98e Mon Sep 17 00:00:00 2001 From: Christian Wellenbrock Date: Mon, 13 Jan 2014 14:27:00 +0100 Subject: [PATCH 2/2] Update version to 2.1.2 --- AdjustIO.podspec | 4 ++-- AdjustIo/AIUtil.m | 2 +- README.md | 2 +- VERSION | 2 +- doc/migration.md | 6 +++--- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/AdjustIO.podspec b/AdjustIO.podspec index 471a51eb0..e0fac1844 100644 --- a/AdjustIO.podspec +++ b/AdjustIO.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = "AdjustIO" - s.version = "2.1.2" + s.version = "2.1.3" s.summary = "This is the iOS SDK of AdjustIo. You can read more about it at http://adjust.io." s.homepage = "http://adjust.io" s.license = { :type => 'MIT', :file => 'MIT-LICENSE' } s.author = { "Christian Wellenbrock" => "welle@adeven.com" } - s.source = { :git => "https://github.com/adeven/adjust_ios_sdk.git", :tag => "v2.1.2" } + s.source = { :git => "https://github.com/adeven/adjust_ios_sdk.git", :tag => "v2.1.3" } s.platform = :ios, '4.3' s.framework = 'AdSupport', 'SystemConfiguration' s.source_files = 'AdjustIo/*.{h,m}', 'AdjustIo/AIAdditions/*.{h,m}' diff --git a/AdjustIo/AIUtil.m b/AdjustIo/AIUtil.m index a298018f4..b06e391a8 100644 --- a/AdjustIo/AIUtil.m +++ b/AdjustIo/AIUtil.m @@ -13,7 +13,7 @@ #include static NSString * const kBaseUrl = @"https://app.adjust.io"; -static NSString * const kClientSdk = @"ios2.1.2"; +static NSString * const kClientSdk = @"ios2.1.3"; #pragma mark - diff --git a/README.md b/README.md index e969bd98e..39be052fb 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ If you're using [CocoaPods][cocoapods], you can add the following line to your `Podfile` and continue with [step 3](#step3): ```ruby -pod 'AdjustIO', :git => 'git://github.com/adeven/adjust_ios_sdk.git', :tag => 'v2.1.2' +pod 'AdjustIO', :git => 'git://github.com/adeven/adjust_ios_sdk.git', :tag => 'v2.1.3' ``` ### 1. Get the SDK diff --git a/VERSION b/VERSION index eca07e4c1..ac2cdeba0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.1.2 +2.1.3 diff --git a/doc/migration.md b/doc/migration.md index cca85ed60..85805f0f3 100644 --- a/doc/migration.md +++ b/doc/migration.md @@ -1,7 +1,7 @@ -## Migrate your AdjustIo SDK for iOS from v1.x to v2.1.2 +## Migrate your AdjustIo SDK for iOS from v1.x to v2.1.3 1. Delete the old `AdjustIo` source folder from your Xcode project. Download - version v2.1.2 and drag the new folder into your Xcode project. + version v2.1.3 and drag the new folder into your Xcode project. ![][drag] @@ -55,7 +55,7 @@ 2. The `appDidLaunch` method now expects your App Token instead of your App ID. You can find your App Token in your [dashboard]. -2. The AdjustIo SDK for iOS 2.1.2 uses [ARC][arc]. If you haven't done already, +2. The AdjustIo SDK for iOS 2.1.3 uses [ARC][arc]. If you haven't done already, we recommend [transitioning your project to use ARC][transition] as well. If you don't want to use ARC, you have to enable ARC for all files of the AdjustIo SDK. Please consult the [README] for details.