diff --git a/HelloSift/Cartfile b/HelloSift/Cartfile index bd6ab7d..bd3235a 100644 --- a/HelloSift/Cartfile +++ b/HelloSift/Cartfile @@ -1 +1 @@ -github "SiftScience/sift-ios" ~> 2.1.1 +github "SiftScience/sift-ios" ~> 2.1.1 \ No newline at end of file diff --git a/Sift.xcodeproj/project.pbxproj b/Sift.xcodeproj/project.pbxproj index b467a55..213a3ba 100644 --- a/Sift.xcodeproj/project.pbxproj +++ b/Sift.xcodeproj/project.pbxproj @@ -424,7 +424,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.2; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -477,7 +477,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.2; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; TARGETED_DEVICE_FAMILY = "1,2"; @@ -498,7 +498,7 @@ "GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = "DEBUG=1"; INFOPLIST_FILE = Sift/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.2; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.sift.Sift; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -518,7 +518,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = Sift/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 9.2; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.sift.Sift; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/Sift.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Sift.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Sift.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Sift/NSData+GZIP.m b/Sift/NSData+GZIP.m index 05b0acd..521472b 100755 --- a/Sift/NSData+GZIP.m +++ b/Sift/NSData+GZIP.m @@ -41,7 +41,7 @@ @implementation NSData (GZIP) -static void *libzOpen() +static void *libzOpen(void) { static void *libz; static dispatch_once_t onceToken; diff --git a/Sift/Sift.m b/Sift/Sift.m index 64a449b..e309a76 100644 --- a/Sift/Sift.m +++ b/Sift/Sift.m @@ -294,44 +294,24 @@ - (void)archiveKeys { [archive setObject:_userId forKey:SF_SIFT_USER_ID]; } NSError *error; - #if TARGET_OS_MACCATALYST - if ([self archivePathForKeys] != nil) { - NSData* data = [NSKeyedArchiver archivedDataWithRootObject: archive requiringSecureCoding:NO error:&error]; - [data writeToFile:[self archivePathForKeys] options:NSDataWritingAtomic error:&error]; - SF_DEBUG(@"Write returned error: %@", [error localizedDescription]); - } - #else - if (@available(iOS 11.0, *)) { - if ([self archivePathForKeys] != nil) { - NSData* data = [NSKeyedArchiver archivedDataWithRootObject: archive requiringSecureCoding:NO error:&error]; - [data writeToFile:[self archivePathForKeys] options:NSDataWritingAtomic error:&error]; - SF_DEBUG(@"Write returned error: %@", [error localizedDescription]); - } - } else { - [NSKeyedArchiver archiveRootObject:archive toFile:[self archivePathForKeys]]; - } - #endif + + if ([self archivePathForKeys] != nil) { + NSData* data = [NSKeyedArchiver archivedDataWithRootObject: archive requiringSecureCoding:NO error:&error]; + [data writeToFile:[self archivePathForKeys] options:NSDataWritingAtomic error:&error]; + SF_DEBUG(@"Write returned error: %@", [error localizedDescription]); + } + } - (void)unarchiveKeys { NSDictionary *archive; NSData *newData = [NSData dataWithContentsOfFile:[self archivePathForKeys]]; NSError *error; - #if TARGET_OS_MACCATALYST - NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:newData error:&error]; - unarchiver.requiresSecureCoding = NO; - archive = [unarchiver decodeTopLevelObjectForKey:NSKeyedArchiveRootObjectKey error:&error]; - SF_DEBUG(@"error unarchiving data: %@", error.localizedDescription); - #else - if (@available(iOS 11.0, *)) { - NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:newData error:&error]; - unarchiver.requiresSecureCoding = NO; - archive = [unarchiver decodeTopLevelObjectForKey:NSKeyedArchiveRootObjectKey error:&error]; - SF_DEBUG(@"error unarchiving data: %@", error.localizedDescription); - } else { - archive = [NSKeyedUnarchiver unarchiveObjectWithFile:[self archivePathForKeys]]; - } - #endif + + NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:newData error:&error]; + unarchiver.requiresSecureCoding = NO; + archive = [unarchiver decodeTopLevelObjectForKey:NSKeyedArchiveRootObjectKey error:&error]; + SF_DEBUG(@"error unarchiving data: %@", error.localizedDescription); if (archive) { _accountId = [archive objectForKey:SF_SIFT_ACCOUNT_ID]; diff --git a/Sift/SiftIosAppState.m b/Sift/SiftIosAppState.m index 851836a..9190b24 100644 --- a/Sift/SiftIosAppState.m +++ b/Sift/SiftIosAppState.m @@ -15,11 +15,11 @@ #import "Sift.h" #import "SiftIosAppState.h" -NSMutableDictionary *SFMakeEmptyIosAppState() { +NSMutableDictionary *SFMakeEmptyIosAppState(void) { return [NSMutableDictionary new]; } -NSMutableDictionary *SFMakeLocation() { +NSMutableDictionary *SFMakeLocation(void) { return [NSMutableDictionary new]; } @@ -84,7 +84,7 @@ return dict; } -static SF_GENERICS(NSArray, NSString *) *getIpAddresses() { +static SF_GENERICS(NSArray, NSString *) *getIpAddresses(void) { struct ifaddrs *interfaces; if (getifaddrs(&interfaces)) { SF_DEBUG(@"Cannot get network interface: %s", strerror(errno)); diff --git a/Sift/SiftIosAppStateCollector.m b/Sift/SiftIosAppStateCollector.m index 1282c9b..67c9c93 100644 --- a/Sift/SiftIosAppStateCollector.m +++ b/Sift/SiftIosAppStateCollector.m @@ -208,17 +208,10 @@ - (void)collectWithTitle:(NSString *)title andTimestamp:(SFTimestamp)now { - (void)archive { dispatch_sync(_serial, ^{ NSDictionary *archive = @{SF_BUCKET: _bucket, SF_LAST_COLLECTED_AT: @(_lastCollectedAt)}; - #if TARGET_OS_MACCATALYST - NSData* data = [NSKeyedArchiver archivedDataWithRootObject: archive requiringSecureCoding:NO error:nil]; - [data writeToFile:self->_archivePath options:NSDataWritingAtomic error:nil]; - #else - if (@available(iOS 11.0, *)) { - NSData* data = [NSKeyedArchiver archivedDataWithRootObject: archive requiringSecureCoding:NO error:nil]; - [data writeToFile:self->_archivePath options:NSDataWritingAtomic error:nil]; - } else { - [NSKeyedArchiver archiveRootObject:archive toFile:self->_archivePath]; - } - #endif + + NSData* data = [NSKeyedArchiver archivedDataWithRootObject: archive requiringSecureCoding:NO error:nil]; + [data writeToFile:self->_archivePath options:NSDataWritingAtomic error:nil]; + }); } @@ -227,21 +220,12 @@ - (void)unarchive { NSDictionary *archive; NSData *newData = [NSData dataWithContentsOfFile:_archivePath]; NSError *error; - #if TARGET_OS_MACCATALYST - NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:newData error:&error]; - unarchiver.requiresSecureCoding = NO; - archive = [unarchiver decodeTopLevelObjectForKey:NSKeyedArchiveRootObjectKey error:&error]; - SF_DEBUG(@"error unarchiving data: %@", error.localizedDescription); - #else - if (@available(iOS 11.0, *)) { - NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:newData error:&error]; - unarchiver.requiresSecureCoding = NO; - archive = [unarchiver decodeTopLevelObjectForKey:NSKeyedArchiveRootObjectKey error:&error]; - SF_DEBUG(@"error unarchiving data: %@", error.localizedDescription); - } else { - archive = [NSKeyedUnarchiver unarchiveObjectWithFile:_archivePath]; - } - #endif + + NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:newData error:&error]; + unarchiver.requiresSecureCoding = NO; + archive = [unarchiver decodeTopLevelObjectForKey:NSKeyedArchiveRootObjectKey error:&error]; + SF_DEBUG(@"error unarchiving data: %@", error.localizedDescription); + if (archive) { _bucket = archive[SF_BUCKET]; _lastCollectedAt = ((NSNumber *)archive[SF_LAST_COLLECTED_AT]).unsignedLongLongValue; diff --git a/Sift/SiftIosDeviceProperties.m b/Sift/SiftIosDeviceProperties.m index c44b930..8ed924b 100644 --- a/Sift/SiftIosDeviceProperties.m +++ b/Sift/SiftIosDeviceProperties.m @@ -1,5 +1,6 @@ // Copyright (c) 2016 Sift Science. All rights reserved. +#include #if !TARGET_OS_MACCATALYST @import CoreTelephony; #endif @@ -17,7 +18,7 @@ #import "SiftIosDeviceProperties.h" -NSMutableDictionary *SFMakeEmptyIosDeviceProperties() { +NSMutableDictionary *SFMakeEmptyIosDeviceProperties(void) { return [NSMutableDictionary new]; } @@ -31,7 +32,7 @@ static BOOL SFIsUrlSchemeWhitelisted(NSString *targetScheme); -NSMutableDictionary *SFCollectIosDeviceProperties() { +NSMutableDictionary *SFCollectIosDeviceProperties(void) { NSMutableDictionary *iosDeviceProperties = SFMakeEmptyIosDeviceProperties(); NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary]; @@ -52,7 +53,10 @@ #if !TARGET_OS_MACCATALYST CTTelephonyNetworkInfo *networkInfo = [CTTelephonyNetworkInfo new]; - CTCarrier *carrier = [networkInfo subscriberCellularProvider]; + + NSDictionary *providers= [networkInfo serviceSubscriberCellularProviders]; + CTCarrier *carrier = providers.allValues.firstObject; + if (carrier) { [iosDeviceProperties setValue:carrier.carrierName forKey:@"mobile_carrier_name"]; [iosDeviceProperties setValue:carrier.isoCountryCode forKey:@"mobile_iso_country_code"]; diff --git a/Sift/SiftQueue.m b/Sift/SiftQueue.m index b9a1796..2340fea 100644 --- a/Sift/SiftQueue.m +++ b/Sift/SiftQueue.m @@ -99,17 +99,10 @@ - (void)archive { [archive setObject:_lastEvent forKey:SF_LAST_EVENT]; } [archive setObject:@(_lastUploadTimestamp) forKey:SF_LAST_UPLOAD_TIMESTAMP]; - #if TARGET_OS_MACCATALYST - NSData* data = [NSKeyedArchiver archivedDataWithRootObject: archive requiringSecureCoding:NO error:nil]; - [data writeToFile:self->_archivePath options:NSDataWritingAtomic error:nil]; - #else - if (@available(iOS 11.0, *)) { - NSData* data = [NSKeyedArchiver archivedDataWithRootObject: archive requiringSecureCoding:NO error:nil]; - [data writeToFile:self->_archivePath options:NSDataWritingAtomic error:nil]; - } else { - [NSKeyedArchiver archiveRootObject:archive toFile:self->_archivePath]; - } - #endif + + NSData* data = [NSKeyedArchiver archivedDataWithRootObject: archive requiringSecureCoding:NO error:nil]; + [data writeToFile:self->_archivePath options:NSDataWritingAtomic error:nil]; + } } @@ -118,21 +111,12 @@ - (void)unarchive { NSDictionary *archive; NSError *error; NSData *newData = [NSData dataWithContentsOfFile:_archivePath]; - #if TARGET_OS_MACCATALYST - NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:newData error:&error]; - unarchiver.requiresSecureCoding = NO; - archive = [unarchiver decodeTopLevelObjectForKey:NSKeyedArchiveRootObjectKey error:&error]; - SF_DEBUG(@"error unarchiving data: %@", error.localizedDescription); - #else - if (@available(iOS 11.0, *)) { - NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:newData error:&error]; - unarchiver.requiresSecureCoding = NO; - archive = [unarchiver decodeTopLevelObjectForKey:NSKeyedArchiveRootObjectKey error:&error]; - SF_DEBUG(@"error unarchiving data: %@", error.localizedDescription); - } else { - archive = [NSKeyedUnarchiver unarchiveObjectWithFile:_archivePath]; - } - #endif + + NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:newData error:&error]; + unarchiver.requiresSecureCoding = NO; + archive = [unarchiver decodeTopLevelObjectForKey:NSKeyedArchiveRootObjectKey error:&error]; + SF_DEBUG(@"error unarchiving data: %@", error.localizedDescription); + if (archive) { _queue = [NSMutableArray arrayWithArray:[archive objectForKey:SF_QUEUE]]; _lastEvent = [archive objectForKey:SF_LAST_EVENT]; diff --git a/Sift/SiftUploader.m b/Sift/SiftUploader.m index 956c2da..86c188a 100644 --- a/Sift/SiftUploader.m +++ b/Sift/SiftUploader.m @@ -207,17 +207,10 @@ - (void)doUpload { - (void)archive { [self->_taskManager submitWithTask:^{ NSDictionary *archive = @{SF_BATCHES: self->_batches, SF_NUM_REJECTS: @(self->_numRejects)}; - #if TARGET_OS_MACCATALYST + NSData* data = [NSKeyedArchiver archivedDataWithRootObject: archive requiringSecureCoding:NO error:nil]; [data writeToFile:self->_archivePath options:NSDataWritingAtomic error:nil]; - #else - if (@available(iOS 11.0, *)) { - NSData* data = [NSKeyedArchiver archivedDataWithRootObject: archive requiringSecureCoding:NO error:nil]; - [data writeToFile:self->_archivePath options:NSDataWritingAtomic error:nil]; - } else { - [NSKeyedArchiver archiveRootObject:archive toFile:self->_archivePath]; - } - #endif + } queue:_serial]; } @@ -226,21 +219,12 @@ - (void)unarchive { NSDictionary *archive; NSData *newData = [NSData dataWithContentsOfFile:_archivePath]; NSError *error; - #if TARGET_OS_MACCATALYST - NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:newData error:&error]; - unarchiver.requiresSecureCoding = NO; - archive = [unarchiver decodeTopLevelObjectForKey:NSKeyedArchiveRootObjectKey error:&error]; - SF_DEBUG(@"error unarchiving data: %@", error.localizedDescription); - #else - if (@available(iOS 11.0, *)) { - NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:newData error:&error]; - unarchiver.requiresSecureCoding = NO; - archive = [unarchiver decodeTopLevelObjectForKey:NSKeyedArchiveRootObjectKey error:&error]; - SF_DEBUG(@"error unarchiving data: %@", error.localizedDescription); - } else { - archive = [NSKeyedUnarchiver unarchiveObjectWithFile:_archivePath]; - } - #endif + + NSKeyedUnarchiver* unarchiver = [[NSKeyedUnarchiver alloc] initForReadingFromData:newData error:&error]; + unarchiver.requiresSecureCoding = NO; + archive = [unarchiver decodeTopLevelObjectForKey:NSKeyedArchiveRootObjectKey error:&error]; + SF_DEBUG(@"error unarchiving data: %@", error.localizedDescription); + if (archive) { _batches = [NSMutableArray arrayWithArray:[archive objectForKey:SF_BATCHES]]; _numRejects = ((NSNumber *)[archive objectForKey:SF_NUM_REJECTS]).intValue;