Skip to content

Commit

Permalink
fix: warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
YoloMao committed May 7, 2024
1 parent 1ead24e commit 335927d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
3 changes: 3 additions & 0 deletions GrowingTrackerCore/Network/GrowingNetworkInterfaceManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ - (NSString *)networkType {
}
}
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
accessString = self.teleInfo.currentRadioAccessTechnology;
#pragma clang diagnostic pop
}

if ([typeStrings4G containsObject:accessString]) {
Expand Down
31 changes: 28 additions & 3 deletions GrowingTrackerCore/Utils/GrowingKeyChainWrapper.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#import "GrowingTrackerCore/Utils/GrowingKeyChainWrapper.h"
#import "GrowingTrackerCore/Thirdparty/Logger/GrowingLogger.h"
#import "GrowingTargetConditionals.h"

@implementation GrowingKeyChainWrapper

Expand All @@ -30,7 +31,20 @@ + (void)setKeychainObject:(id)value forKey:(NSString *)service {
SecItemDelete((CFDictionaryRef)keychainQuery);

// Add new object to search dictionary(Attention:the data format)
[keychainQuery setObject:[NSKeyedArchiver archivedDataWithRootObject:value] forKey:(id)kSecValueData];
#if Growing_OS_VISION
if (1) { // if (@available(visionOS 1.0, *)) {
#else
if (@available(iOS 11.0, macCatalyst 13.1, macOS 10.13, tvOS 11.0, watchOS 4.0, *)) {
#endif
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:value requiringSecureCoding:YES error:nil];
[keychainQuery setObject:data forKey:(id)kSecValueData];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:value];
[keychainQuery setObject:data forKey:(id)kSecValueData];
#pragma clang diagnostic pop
}

// Add item to keychain with the search dictionary
SecItemAdd((CFDictionaryRef)keychainQuery, NULL);
Expand All @@ -48,7 +62,18 @@ + (id)keyChainObjectForKey:(NSString *)key {
CFDataRef keyData = NULL;
if (SecItemCopyMatching((CFDictionaryRef)keychainQuery, (CFTypeRef *)&keyData) == noErr) {
@try {
ret = [NSKeyedUnarchiver unarchiveObjectWithData:(__bridge NSData *)keyData];
#if Growing_OS_VISION
if (1) { // if (@available(visionOS 1.0, *)) {
#else
if (@available(iOS 11.0, macCatalyst 13.1, macOS 10.13, tvOS 11.0, watchOS 4.0, *)) {
#endif
ret = [NSKeyedUnarchiver unarchivedObjectOfClass:[NSString class] fromData:(__bridge NSData *)keyData error:nil];
} else {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
ret = [NSKeyedUnarchiver unarchiveObjectWithData:(__bridge NSData *)keyData];
#pragma clang diagnostic pop
}
} @catch (NSException *e) {
GIOLogError(@"GrowingIO Unarchive of %@ failed: %@", key, e);
} @finally {
Expand All @@ -66,7 +91,7 @@ + (NSMutableDictionary *)getKeychainQuery:(NSString *)key {
(id)kSecAttrService,
key,
(id)kSecAttrAccount,
(id)kSecAttrAccessibleAlwaysThisDeviceOnly,
(id)kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly,
(id)kSecAttrAccessible,
nil];
}
Expand Down

0 comments on commit 335927d

Please sign in to comment.