From 335927d09120040a0b4f62e12b671ca863002da2 Mon Sep 17 00:00:00 2001 From: YoloMao Date: Tue, 7 May 2024 11:10:36 +0800 Subject: [PATCH] fix: warnings --- .../Network/GrowingNetworkInterfaceManager.m | 3 ++ .../Utils/GrowingKeyChainWrapper.m | 31 +++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/GrowingTrackerCore/Network/GrowingNetworkInterfaceManager.m b/GrowingTrackerCore/Network/GrowingNetworkInterfaceManager.m index 27931f1f5..8a507c0b3 100644 --- a/GrowingTrackerCore/Network/GrowingNetworkInterfaceManager.m +++ b/GrowingTrackerCore/Network/GrowingNetworkInterfaceManager.m @@ -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]) { diff --git a/GrowingTrackerCore/Utils/GrowingKeyChainWrapper.m b/GrowingTrackerCore/Utils/GrowingKeyChainWrapper.m index 5560ccc8f..86ae451b5 100644 --- a/GrowingTrackerCore/Utils/GrowingKeyChainWrapper.m +++ b/GrowingTrackerCore/Utils/GrowingKeyChainWrapper.m @@ -19,6 +19,7 @@ #import "GrowingTrackerCore/Utils/GrowingKeyChainWrapper.h" #import "GrowingTrackerCore/Thirdparty/Logger/GrowingLogger.h" +#import "GrowingTargetConditionals.h" @implementation GrowingKeyChainWrapper @@ -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); @@ -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 { @@ -66,7 +91,7 @@ + (NSMutableDictionary *)getKeychainQuery:(NSString *)key { (id)kSecAttrService, key, (id)kSecAttrAccount, - (id)kSecAttrAccessibleAlwaysThisDeviceOnly, + (id)kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly, (id)kSecAttrAccessible, nil]; }