Skip to content

Commit

Permalink
chore: Fixing additional deprecation warnings and updating README
Browse files Browse the repository at this point in the history
  • Loading branch information
sebaland committed Apr 9, 2024
1 parent a30c751 commit d5072de
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ typedef NS_ENUM(NSInteger, AWSCognitoAuthUICKeyChainStoreAuthenticationType) {
typedef NS_ENUM(NSInteger, AWSCognitoAuthUICKeyChainStoreAccessibility) {
AWSCognitoAuthUICKeyChainStoreAccessibilityWhenUnlocked = 1,
AWSCognitoAuthUICKeyChainStoreAccessibilityAfterFirstUnlock,
AWSCognitoAuthUICKeyChainStoreAccessibilityAlways,
AWSCognitoAuthUICKeyChainStoreAccessibilityAlways __deprecated_enum_msg("Use an accessibility level that provides some user protection, such as AWSCognitoAuthUICKeyChainStoreAccessibilityAfterFirstUnlock"),
AWSCognitoAuthUICKeyChainStoreAccessibilityWhenPasscodeSetThisDeviceOnly
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0),
AWSCognitoAuthUICKeyChainStoreAccessibilityWhenUnlockedThisDeviceOnly,
AWSCognitoAuthUICKeyChainStoreAccessibilityAfterFirstUnlockThisDeviceOnly,
AWSCognitoAuthUICKeyChainStoreAccessibilityAlwaysThisDeviceOnly,
AWSCognitoAuthUICKeyChainStoreAccessibilityAlwaysThisDeviceOnly __deprecated_enum_msg("Use an accessibility level that provides some user protection, such as AWSCognitoAuthUICKeyChainStoreAccessibilityAfterFirstUnlockThisDeviceOnly"),
}
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_4_0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -527,14 +527,7 @@ - (BOOL)setData:(NSData *)data forKey:(NSString *)key genericAttribute:(id)gener
NSMutableDictionary *query = [self query];
query[(__bridge __strong id)kSecAttrAccount] = key;
#if TARGET_OS_IOS
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if (floor(NSFoundationVersionNumber) > floor(1144.17)) { // iOS 9+
query[(__bridge __strong id)kSecUseAuthenticationUI] = (__bridge id)kSecUseAuthenticationUIFail;
} else if (floor(NSFoundationVersionNumber) > floor(1047.25)) { // iOS 8+
query[(__bridge __strong id)kSecUseNoAuthenticationUI] = (__bridge id)kCFBooleanTrue;
}
#pragma clang diagnostic pop
query[(__bridge __strong id)kSecUseAuthenticationUI] = (__bridge id)kSecUseAuthenticationUIFail;
#elif TARGET_OS_WATCH || TARGET_OS_TV
query[(__bridge __strong id)kSecUseAuthenticationUI] = (__bridge id)kSecUseAuthenticationUIFail;
#endif
Expand Down Expand Up @@ -1094,6 +1087,8 @@ + (NSString *)generatePassword

#pragma mark -

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-implementations"
- (void)synchronize
{
// Deprecated, calling this method is no longer required
Expand All @@ -1104,6 +1099,7 @@ - (BOOL)synchronizeWithError:(NSError *__autoreleasing *)error
// Deprecated, calling this method is no longer required
return true;
}
#pragma clang diagnostic pop

#pragma mark -

Expand Down Expand Up @@ -1348,6 +1344,8 @@ - (CFTypeRef)authenticationTypeObject
}
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (CFTypeRef)accessibilityObject
{
switch (_accessibility) {
Expand All @@ -1369,6 +1367,7 @@ - (CFTypeRef)accessibilityObject
return nil;
}
}
#pragma clang diagnostic pop

+ (NSError *)argumentError:(NSString *)message
{
Expand Down
3 changes: 3 additions & 0 deletions AWSCognitoIdentityProvider/AWSCognitoIdentityUser.m
Original file line number Diff line number Diff line change
Expand Up @@ -1172,6 +1172,8 @@ -(void) addSecretHashDeviceKeyAndUsername:(NSMutableDictionary<NSString *,NSStri
/**
* Invoke developer's ui to prompt user for mfa code and call enhanceAuth
*/
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-(AWSTask<AWSCognitoIdentityUserSession *>*) mfaAuthInternal: (NSString *) deliveryMedium
destination: (NSString *) destination
authState: (NSString *) authState
Expand Down Expand Up @@ -1208,6 +1210,7 @@ -(void) addSecretHashDeviceKeyAndUsername:(NSMutableDictionary<NSString *,NSStri
}];
}
}
#pragma clang diagnostic pop

-(AWSTask<AWSCognitoIdentityUserSession *>*) mfaAuthInternal: (NSString *) deliveryMedium
destination: (NSString *) destination
Expand Down
31 changes: 17 additions & 14 deletions AWSCore/Bolts/AWSTask.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#import "AWSTask.h"

#import <libkern/OSAtomic.h>
#import <stdatomic.h>

#import "AWSBolts.h"

Expand Down Expand Up @@ -98,12 +98,12 @@ + (instancetype)cancelledTask {
}

+ (instancetype)taskForCompletionOfAllTasks:(nullable NSArray<AWSTask *> *)tasks {
__block int32_t total = (int32_t)tasks.count;
__block _Atomic(int32_t) total = (int32_t)tasks.count;
if (total == 0) {
return [self taskWithResult:nil];
}

__block int32_t cancelled = 0;
__block _Atomic(int32_t) cancelled = 0;
NSObject *lock = [[NSObject alloc] init];
NSMutableArray *errors = [NSMutableArray array];

Expand All @@ -115,10 +115,11 @@ + (instancetype)taskForCompletionOfAllTasks:(nullable NSArray<AWSTask *> *)tasks
[errors addObject:t.error];
}
} else if (t.cancelled) {
OSAtomicIncrement32Barrier(&cancelled);
atomic_fetch_add(&cancelled, 1);
}

if (OSAtomicDecrement32Barrier(&total) == 0) {
atomic_fetch_sub(&total, 1);
if (total == 0) {
if (errors.count > 0) {
if (errors.count == 1) {
tcs.error = [errors firstObject];
Expand Down Expand Up @@ -148,14 +149,14 @@ + (instancetype)taskForCompletionOfAllTasksWithResults:(nullable NSArray<AWSTask

+ (instancetype)taskForCompletionOfAnyTask:(nullable NSArray<AWSTask *> *)tasks
{
__block int32_t total = (int32_t)tasks.count;
__block _Atomic(int32_t) total = (int32_t)tasks.count;
if (total == 0) {
return [self taskWithResult:nil];
}

__block int completed = 0;
__block int32_t cancelled = 0;
__block _Atomic(BOOL) completed = NO;
__block _Atomic(int32_t) cancelled = 0;

NSObject *lock = [NSObject new];
NSMutableArray<NSError *> *errors = [NSMutableArray new];

Expand All @@ -167,15 +168,17 @@ + (instancetype)taskForCompletionOfAnyTask:(nullable NSArray<AWSTask *> *)tasks
[errors addObject:t.error];
}
} else if (t.cancelled) {
OSAtomicIncrement32Barrier(&cancelled);
atomic_fetch_add(&cancelled, 1);
} else {
if(OSAtomicCompareAndSwap32Barrier(0, 1, &completed)) {
BOOL expected = NO;
if(atomic_compare_exchange_strong(&completed, &expected, YES)) {
[source setResult:t.result];
}
}

if (OSAtomicDecrement32Barrier(&total) == 0 &&
OSAtomicCompareAndSwap32Barrier(0, 1, &completed)) {

atomic_fetch_sub(&total, 1);
BOOL expected = NO;
if (total == 0 && atomic_compare_exchange_strong(&completed, &expected, YES)) {
if (cancelled > 0) {
[source cancel];
} else if (errors.count > 0) {
Expand Down
4 changes: 2 additions & 2 deletions AWSCore/UICKeyChainStore/AWSUICKeyChainStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ typedef NS_ENUM(NSInteger, AWSUICKeyChainStoreAuthenticationType) {
typedef NS_ENUM(NSInteger, AWSUICKeyChainStoreAccessibility) {
AWSUICKeyChainStoreAccessibilityWhenUnlocked = 1,
AWSUICKeyChainStoreAccessibilityAfterFirstUnlock,
AWSUICKeyChainStoreAccessibilityAlways,
AWSUICKeyChainStoreAccessibilityAlways __deprecated_enum_msg("Use an accessibility level that provides some user protection, such as AWSUICKeyChainStoreAccessibilityAfterFirstUnlock"),
AWSUICKeyChainStoreAccessibilityWhenPasscodeSetThisDeviceOnly
__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0),
AWSUICKeyChainStoreAccessibilityWhenUnlockedThisDeviceOnly,
AWSUICKeyChainStoreAccessibilityAfterFirstUnlockThisDeviceOnly,
AWSUICKeyChainStoreAccessibilityAlwaysThisDeviceOnly,
AWSUICKeyChainStoreAccessibilityAlwaysThisDeviceOnly __deprecated_enum_msg("Use an accessibility level that provides some user protection, such as AWSUICKeyChainStoreAccessibilityAfterFirstUnlockThisDeviceOnly"),
}
__OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_4_0);

Expand Down
3 changes: 3 additions & 0 deletions AWSCore/UICKeyChainStore/AWSUICKeyChainStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,8 @@ - (CFTypeRef)authenticationTypeObject
}
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- (CFTypeRef)accessibilityObject
{
switch (_accessibility) {
Expand All @@ -1358,6 +1360,7 @@ - (CFTypeRef)accessibilityObject
return nil;
}
}
#pragma clang diagnostic pop

+ (NSError *)argumentError:(NSString *)message
{
Expand Down
4 changes: 2 additions & 2 deletions AWSIoT/AWSIoTKeyChainTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, AWSIoTKeyChainAccessibility) {
AWSIoTKeyChainAccessibilityWhenUnlocked = 1,
AWSIoTKeyChainAccessibilityAfterFirstUnlock,
AWSIoTKeyChainAccessibilityAlways,
AWSIoTKeyChainAccessibilityAlways __deprecated_enum_msg("Use an accessibility level that provides some user protection, such as AWSIoTKeyChainAccessibilityAfterFirstUnlock"),
AWSIoTKeyChainAccessibilityWhenPasscodeSetThisDeviceOnly,
AWSIoTKeyChainAccessibilityWhenUnlockedThisDeviceOnly,
AWSIoTKeyChainAccessibilityAfterFirstUnlockThisDeviceOnly,
AWSIoTKeyChainAccessibilityAlwaysThisDeviceOnly,
AWSIoTKeyChainAccessibilityAlwaysThisDeviceOnly __deprecated_enum_msg("Use an accessibility level that provides some user protection, such as AWSIoTKeyChainAccessibilityAfterFirstUnlockThisDeviceOnly"),
};

NS_ASSUME_NONNULL_END
3 changes: 3 additions & 0 deletions AWSIoT/Internal/AWSIoTKeychain.m
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@ + (void)setKeyChainAccessibility:(AWSIoTKeyChainAccessibility)accessibility {
_accessibility = accessibility;
}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ (CFTypeRef)accessibilityType {
switch (_accessibility) {
case AWSIoTKeyChainAccessibilityWhenUnlocked:
Expand All @@ -542,5 +544,6 @@ + (CFTypeRef)accessibilityType {
return nil;
}
}
#pragma clang diagnostic pop

@end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To get started with the AWS SDK for iOS, check out the [Developer Guide for iOS]
To use the AWS SDK for iOS, you will need the following installed on your development machine:

* Xcode 11.0 or later
* iOS 9 or later
* iOS 12 or later

## Include the SDK for iOS in an Existing Application

Expand Down

0 comments on commit d5072de

Please sign in to comment.