Skip to content

Commit

Permalink
Fixed all warnings and changed the base version to 12 (#121)
Browse files Browse the repository at this point in the history
* Fixed all warnings and changed base version to 12

* Cartfile change reverted to original

---------

Co-authored-by: SujishaExalture <[email protected]>
  • Loading branch information
SujishaExalture and sujisha-wisilica authored Jun 14, 2023
1 parent 780024c commit 6465dbd
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 120 deletions.
2 changes: 1 addition & 1 deletion HelloSift/Cartfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "SiftScience/sift-ios" ~> 2.1.1
github "SiftScience/sift-ios" ~> 2.1.1
8 changes: 4 additions & 4 deletions Sift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand All @@ -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)";
Expand All @@ -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)";
Expand Down
8 changes: 8 additions & 0 deletions Sift.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
2 changes: 1 addition & 1 deletion Sift/NSData+GZIP.m
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

@implementation NSData (GZIP)

static void *libzOpen()
static void *libzOpen(void)
{
static void *libz;
static dispatch_once_t onceToken;
Expand Down
44 changes: 12 additions & 32 deletions Sift/Sift.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
6 changes: 3 additions & 3 deletions Sift/SiftIosAppState.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down Expand Up @@ -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));
Expand Down
36 changes: 10 additions & 26 deletions Sift/SiftIosAppStateCollector.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];

});
}

Expand All @@ -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;
Expand Down
10 changes: 7 additions & 3 deletions Sift/SiftIosDeviceProperties.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) 2016 Sift Science. All rights reserved.

#include <TargetConditionals.h>
#if !TARGET_OS_MACCATALYST
@import CoreTelephony;
#endif
Expand All @@ -17,7 +18,7 @@

#import "SiftIosDeviceProperties.h"

NSMutableDictionary *SFMakeEmptyIosDeviceProperties() {
NSMutableDictionary *SFMakeEmptyIosDeviceProperties(void) {
return [NSMutableDictionary new];
}

Expand All @@ -31,7 +32,7 @@

static BOOL SFIsUrlSchemeWhitelisted(NSString *targetScheme);

NSMutableDictionary *SFCollectIosDeviceProperties() {
NSMutableDictionary *SFCollectIosDeviceProperties(void) {
NSMutableDictionary *iosDeviceProperties = SFMakeEmptyIosDeviceProperties();

NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
Expand All @@ -52,7 +53,10 @@

#if !TARGET_OS_MACCATALYST
CTTelephonyNetworkInfo *networkInfo = [CTTelephonyNetworkInfo new];
CTCarrier *carrier = [networkInfo subscriberCellularProvider];

NSDictionary<NSString *, CTCarrier *> *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"];
Expand Down
36 changes: 10 additions & 26 deletions Sift/SiftQueue.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];

}
}

Expand All @@ -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];
Expand Down
32 changes: 8 additions & 24 deletions Sift/SiftUploader.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand All @@ -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;
Expand Down

0 comments on commit 6465dbd

Please sign in to comment.