From 32f870990a9f3e5d1f762f1b97b28f75cc99270a Mon Sep 17 00:00:00 2001 From: yangsen Date: Sun, 22 Oct 2023 02:01:39 -0500 Subject: [PATCH] iOS support min version to 9.0 (#435) --- CHANGELOG.md | 5 +++ Package.swift | 4 +-- Podfile | 8 ++--- Qiniu.podspec | 6 ++-- QiniuSDK.xcodeproj/project.pbxproj | 10 +++--- QiniuSDK/Storage/QNUploadManager.h | 2 +- QiniuSDK/Utils/QNALAssetFile.h | 4 +-- QiniuSDK/Utils/QNALAssetFile.m | 6 ++-- QiniuSDK/Utils/QNMutableArray.m | 34 +++++++++--------- QiniuSDK/Utils/QNSystem.m | 58 +----------------------------- QiniuSDK/Utils/QNVersion.h | 2 +- README.md | 18 +++++----- 12 files changed, 55 insertions(+), 102 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72a6e90d..5f4d6f82 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ #Changelog +## 8.7.0(2023-10-23) +- iOS 最低版本调整至 iOS9 +- QNFixedZone 新增通过 RegionID 构造实例的方法 +- 区域查询结果缓存支持磁盘缓存 + ## 8.6.0(2023-08-07) - 调整在根据 Bucket 获取其所在区域信息时的主备域名顺序 - 移除亚太-首尔区域 diff --git a/Package.swift b/Package.swift index fc087925..1885c4dd 100644 --- a/Package.swift +++ b/Package.swift @@ -6,8 +6,8 @@ import PackageDescription let package = Package( name: "Qiniu", platforms: [ - .macOS(.v10_10), - .iOS(.v8) + .macOS(.v10_15), + .iOS(.v9) ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. diff --git a/Podfile b/Podfile index e6465ceb..079fcb51 100755 --- a/Podfile +++ b/Podfile @@ -10,23 +10,23 @@ def test_dependencies end target 'QiniuSDK_iOS' do - platform :ios, '7.0' + platform :ios, '9.0' shared_dependencies end target 'QiniuSDK_iOSTests' do - platform :ios, '7.0' + platform :ios, '9.0' shared_dependencies test_dependencies end target 'QiniuSDK_Mac' do - platform :osx, '10.9' + platform :osx, '10.15' shared_dependencies end target 'QiniuSDK_MacTests' do - platform :osx, '10.9' + platform :osx, '10.15' shared_dependencies test_dependencies end diff --git a/Qiniu.podspec b/Qiniu.podspec index eead09f5..b49d2a00 100755 --- a/Qiniu.podspec +++ b/Qiniu.podspec @@ -1,14 +1,14 @@ Pod::Spec.new do |s| s.name = 'Qiniu' - s.version = '8.6.0' + s.version = '8.7.0' s.summary = 'Qiniu Resource Storage SDK for iOS and Mac' s.homepage = 'https://github.com/qiniu/objc-sdk' s.social_media_url = 'http://weibo.com/qiniutek' s.author = "Qiniu => sdk@qiniu.com" s.source = {:git => 'https://github.com/qiniu/objc-sdk.git', :tag => "v#{s.version}"} - s.ios.deployment_target = '7.0' - s.osx.deployment_target = '10.9' + s.ios.deployment_target = '9.0' + s.osx.deployment_target = '10.15' s.source_files = 'QiniuSDK/BigData/**/*.{h,m}','QiniuSDK/Collect/**/*.{h,m}','QiniuSDK/Common/**/*.{h,m}','QiniuSDK/Http/**/*.{h,m}','QiniuSDK/Recorder/**/*.{h,m}','QiniuSDK/Storage/**/*.{h,m}','QiniuSDK/Transaction/**/*.{h,m}','QiniuSDK/Utils/**/*.{h,m}','QiniuSDK/QiniuSDK.h' s.requires_arc = true diff --git a/QiniuSDK.xcodeproj/project.pbxproj b/QiniuSDK.xcodeproj/project.pbxproj index 4529c744..d02dc126 100644 --- a/QiniuSDK.xcodeproj/project.pbxproj +++ b/QiniuSDK.xcodeproj/project.pbxproj @@ -1854,8 +1854,8 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MACOSX_DEPLOYMENT_TARGET = 10.14; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; OTHER_LDFLAGS = "$(inherited)"; @@ -1903,8 +1903,8 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; - MACOSX_DEPLOYMENT_TARGET = 10.14; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = NO; OTHER_LDFLAGS = "$(inherited)"; SDKROOT = macosx; @@ -2020,6 +2020,7 @@ GCC_OPTIMIZATION_LEVEL = 0; GENERATE_INFOPLIST_FILE = YES; GENERATE_PKGINFO_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; PRODUCT_NAME = QiniuSDK_iOSTests; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = iphoneos; @@ -2038,6 +2039,7 @@ DEVELOPMENT_TEAM = ""; GENERATE_INFOPLIST_FILE = YES; GENERATE_PKGINFO_FILE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; PRODUCT_NAME = QiniuSDK_iOSTests; PROVISIONING_PROFILE_SPECIFIER = ""; SDKROOT = iphoneos; diff --git a/QiniuSDK/Storage/QNUploadManager.h b/QiniuSDK/Storage/QNUploadManager.h index 3a1f63c2..80f78c59 100755 --- a/QiniuSDK/Storage/QNUploadManager.h +++ b/QiniuSDK/Storage/QNUploadManager.h @@ -145,7 +145,7 @@ typedef void (^QNUpCompletionHandler)(QNResponseInfo *info, NSString *key, NSDic key:(NSString *)key token:(NSString *)token complete:(QNUpCompletionHandler)completionHandler - option:(QNUploadOption *)option API_UNAVAILABLE(macos, tvos); + option:(QNUploadOption *)option API_DEPRECATED("use putPHAsset instead", ios(4.0, 9.0)) API_UNAVAILABLE(macos, tvos); #endif /** diff --git a/QiniuSDK/Utils/QNALAssetFile.h b/QiniuSDK/Utils/QNALAssetFile.h index 594240fe..a5977930 100755 --- a/QiniuSDK/Utils/QNALAssetFile.h +++ b/QiniuSDK/Utils/QNALAssetFile.h @@ -13,7 +13,7 @@ #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) #if !TARGET_OS_MACCATALYST @class ALAsset; -@interface QNALAssetFile : NSObject +@interface QNALAssetFile : NSObject ; /** * 打开指定文件 @@ -24,7 +24,7 @@ * @return 实例 */ - (instancetype)init:(ALAsset *)asset - error:(NSError *__autoreleasing *)error; + error:(NSError *__autoreleasing *)error NS_DEPRECATED_IOS(4_0, 9_0); @end #endif #endif diff --git a/QiniuSDK/Utils/QNALAssetFile.m b/QiniuSDK/Utils/QNALAssetFile.m index 29b84eb2..abadd8f7 100755 --- a/QiniuSDK/Utils/QNALAssetFile.m +++ b/QiniuSDK/Utils/QNALAssetFile.m @@ -15,7 +15,7 @@ @interface QNALAssetFile () -@property (nonatomic) ALAsset *asset; +@property (nonatomic) ALAsset *asset NS_DEPRECATED_IOS(4_0, 9_0); @property (readonly) int64_t fileSize; @@ -45,7 +45,7 @@ - (instancetype)init:(ALAsset *)asset - (NSData *)read:(long long)offset size:(long)size - error:(NSError **)error { + error:(NSError **)error NS_DEPRECATED_IOS(4_0, 9_0) { NSData *data = nil; @try { @@ -70,7 +70,7 @@ - (NSData *)readAllWithError:(NSError **)error { - (void)close { } -- (NSString *)path { +- (NSString *)path NS_DEPRECATED_IOS(4_0, 9_0) { ALAssetRepresentation *rep = [self.asset defaultRepresentation]; return [rep url].path; } diff --git a/QiniuSDK/Utils/QNMutableArray.m b/QiniuSDK/Utils/QNMutableArray.m index 5ec88b86..20dd9c4b 100644 --- a/QiniuSDK/Utils/QNMutableArray.m +++ b/QiniuSDK/Utils/QNMutableArray.m @@ -134,11 +134,11 @@ - (NSData *)sortedArrayHint { LOCK(NSData * d = [_arr sortedArrayHint]); return d; } -- (NSArray *)sortedArrayUsingFunction:(NSInteger (*)(id, id, void *))comparator context:(void *)context { +- (NSArray *)sortedArrayUsingFunction:(NSInteger (NS_NOESCAPE *)(id, id, void *))comparator context:(void *)context { LOCK(NSArray * arr = [_arr sortedArrayUsingFunction:comparator context:context]) return arr; } -- (NSArray *)sortedArrayUsingFunction:(NSInteger (*)(id, id, void *))comparator context:(void *)context hint:(NSData *)hint { +- (NSArray *)sortedArrayUsingFunction:(NSInteger (NS_NOESCAPE *)(id, id, void *))comparator context:(void *)context hint:(NSData *)hint { LOCK(NSArray * arr = [_arr sortedArrayUsingFunction:comparator context:context hint:hint]); return arr; } @@ -166,51 +166,51 @@ - (id)objectAtIndexedSubscript:(NSUInteger)idx { LOCK(id o = [_arr objectAtIndexedSubscript:idx]); return o; } -- (void)enumerateObjectsUsingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop))block { +- (void)enumerateObjectsUsingBlock:(void (NS_NOESCAPE ^)(id obj, NSUInteger idx, BOOL *stop))block { LOCK([_arr enumerateObjectsUsingBlock:block]); } -- (void)enumerateObjectsWithOptions:(NSEnumerationOptions)opts usingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop))block { +- (void)enumerateObjectsWithOptions:(NSEnumerationOptions)opts usingBlock:(void (NS_NOESCAPE ^)(id obj, NSUInteger idx, BOOL *stop))block { LOCK([_arr enumerateObjectsWithOptions:opts usingBlock:block]); } -- (void)enumerateObjectsAtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts usingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop))block { +- (void)enumerateObjectsAtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts usingBlock:(void (NS_NOESCAPE ^)(id obj, NSUInteger idx, BOOL *stop))block { LOCK([_arr enumerateObjectsAtIndexes:s options:opts usingBlock:block]); } -- (NSUInteger)indexOfObjectPassingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate { +- (NSUInteger)indexOfObjectPassingTest:(BOOL (NS_NOESCAPE ^)(id obj, NSUInteger idx, BOOL *stop))predicate { LOCK(NSUInteger i = [_arr indexOfObjectPassingTest:predicate]); return i; } -- (NSUInteger)indexOfObjectWithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate { +- (NSUInteger)indexOfObjectWithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (NS_NOESCAPE ^)(id obj, NSUInteger idx, BOOL *stop))predicate { LOCK(NSUInteger i = [_arr indexOfObjectWithOptions:opts passingTest:predicate]); return i; } -- (NSUInteger)indexOfObjectAtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate { +- (NSUInteger)indexOfObjectAtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (NS_NOESCAPE ^)(id obj, NSUInteger idx, BOOL *stop))predicate { LOCK(NSUInteger i = [_arr indexOfObjectAtIndexes:s options:opts passingTest:predicate]); return i; } -- (NSIndexSet *)indexesOfObjectsPassingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate { +- (NSIndexSet *)indexesOfObjectsPassingTest:(BOOL (NS_NOESCAPE ^)(id obj, NSUInteger idx, BOOL *stop))predicate { LOCK(NSIndexSet * i = [_arr indexesOfObjectsPassingTest:predicate]); return i; } -- (NSIndexSet *)indexesOfObjectsWithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate { +- (NSIndexSet *)indexesOfObjectsWithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (NS_NOESCAPE ^)(id obj, NSUInteger idx, BOOL *stop))predicate { LOCK(NSIndexSet * i = [_arr indexesOfObjectsWithOptions:opts passingTest:predicate]); return i; } -- (NSIndexSet *)indexesOfObjectsAtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate { +- (NSIndexSet *)indexesOfObjectsAtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (NS_NOESCAPE ^)(id obj, NSUInteger idx, BOOL *stop))predicate { LOCK(NSIndexSet * i = [_arr indexesOfObjectsAtIndexes:s options:opts passingTest:predicate]); return i; } -- (NSArray *)sortedArrayUsingComparator:(NSComparator)cmptr { +- (NSArray *)sortedArrayUsingComparator:(NSComparator NS_NOESCAPE)cmptr { LOCK(NSArray * a = [_arr sortedArrayUsingComparator:cmptr]); return a; } -- (NSArray *)sortedArrayWithOptions:(NSSortOptions)opts usingComparator:(NSComparator)cmptr { +- (NSArray *)sortedArrayWithOptions:(NSSortOptions)opts usingComparator:(NSComparator NS_NOESCAPE)cmptr { LOCK(NSArray * a = [_arr sortedArrayWithOptions:opts usingComparator:cmptr]); return a; } -- (NSUInteger)indexOfObject:(id)obj inSortedRange:(NSRange)r options:(NSBinarySearchingOptions)opts usingComparator:(NSComparator)cmp { +- (NSUInteger)indexOfObject:(id)obj inSortedRange:(NSRange)r options:(NSBinarySearchingOptions)opts usingComparator:(NSComparator NS_NOESCAPE)cmp { LOCK(NSUInteger i = [_arr indexOfObject:obj inSortedRange:r options:opts usingComparator:cmp]); return i; } @@ -284,7 +284,7 @@ - (void)setArray:(NSArray *)otherArray { LOCK([_arr setArray:otherArray]); } -- (void)sortUsingFunction:(NSInteger (*)(id, id, void *))compare context:(void *)context { +- (void)sortUsingFunction:(NSInteger (NS_NOESCAPE *)(id, id, void *))compare context:(void *)context { LOCK([_arr sortUsingFunction:compare context:context]); } @@ -308,11 +308,11 @@ - (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx { LOCK([_arr setObject:obj atIndexedSubscript:idx]); } -- (void)sortUsingComparator:(NSComparator)cmptr { +- (void)sortUsingComparator:(NSComparator NS_NOESCAPE)cmptr { LOCK([_arr sortUsingComparator:cmptr]); } -- (void)sortWithOptions:(NSSortOptions)opts usingComparator:(NSComparator)cmptr { +- (void)sortWithOptions:(NSSortOptions)opts usingComparator:(NSComparator NS_NOESCAPE)cmptr { LOCK([_arr sortWithOptions:opts usingComparator:cmptr]); } diff --git a/QiniuSDK/Utils/QNSystem.m b/QiniuSDK/Utils/QNSystem.m index ed5c4038..afa85128 100755 --- a/QiniuSDK/Utils/QNSystem.m +++ b/QiniuSDK/Utils/QNSystem.m @@ -15,63 +15,7 @@ #import #endif -BOOL hasNSURLSession() { -#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) - float sysVersion = [[[UIDevice currentDevice] systemVersion] floatValue]; - if (sysVersion < 7.0) { - return NO; - } -#else - NSOperatingSystemVersion sysVersion = [[NSProcessInfo processInfo] operatingSystemVersion]; - if (sysVersion.majorVersion < 10) { - return NO; - } else if (sysVersion.majorVersion == 10) { - return sysVersion.minorVersion >= 9; - } -#endif - return YES; -} - -BOOL hasAts() { -#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) - float sysVersion = [[[UIDevice currentDevice] systemVersion] floatValue]; - if (sysVersion < 9.0) { - return NO; - } -#else - NSOperatingSystemVersion sysVersion = [[NSProcessInfo processInfo] operatingSystemVersion]; - if (sysVersion.majorVersion < 10) { - return NO; - } else if (sysVersion.majorVersion == 10) { - return sysVersion.minorVersion >= 11; - } -#endif - return YES; -} - -BOOL allowsArbitraryLoads() { - if (!hasAts()) { - return YES; - } - - // for unit test - NSDictionary* d = [[NSBundle mainBundle] infoDictionary]; - if (d == nil || d.count == 0) { - return YES; - } - - NSDictionary* sec = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSAppTransportSecurity"]; - if (sec == nil) { - return NO; - } - NSNumber* ats = [sec objectForKey:@"NSAllowsArbitraryLoads"]; - if (ats == nil) { - return NO; - } - return ats.boolValue; -} - -BOOL isIpV6FullySupported() { +BOOL isIpV6FullySupported(void) { #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) float sysVersion = [[[UIDevice currentDevice] systemVersion] floatValue]; if (sysVersion < 9.0) { diff --git a/QiniuSDK/Utils/QNVersion.h b/QiniuSDK/Utils/QNVersion.h index 1da360d2..45350979 100755 --- a/QiniuSDK/Utils/QNVersion.h +++ b/QiniuSDK/Utils/QNVersion.h @@ -11,4 +11,4 @@ /** * sdk 版本 */ -static NSString *const kQiniuVersion = @"8.6.0"; +static NSString *const kQiniuVersion = @"8.7.0"; diff --git a/README.md b/README.md index 91a45677..11837321 100755 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ 通过 CocoaPods ```ruby -pod "Qiniu", "~> 8.6.0" +pod "Qiniu", "~> 8.7.0" ``` 通过 Swift Package Manager (Xcode 11+) @@ -26,7 +26,7 @@ File -> Swift Packages -> Add Package Dependency,输入库链接,选择相 库对接: let package = Package( dependencies: [ - .package(url: "https://github.com/qiniu/objc-sdk", from: "8.5.3") + .package(url: "https://github.com/qiniu/objc-sdk", from: "8.7.0") ], // ... ) @@ -37,6 +37,7 @@ let package = Package( | Qiniu SDK 版本 | 最低 iOS版本 | 最低 OS X 版本 | Notes | | :--------------------------------------: | :------: | :--------: | :-----------: | +| 8.7.x | iOS 9 | OS X 10.15 | Xcode 最低版本 11 | | 8.6.x | iOS 7 | OS X 10.15 | Xcode 最低版本 11 | | 8.5.x | iOS 7 | OS X 10.15 | Xcode 最低版本 11 | | 8.4.x | iOS 7 | OS X 10.15 | Xcode 最低版本 11 | @@ -75,12 +76,13 @@ let package = Package( #import ... QNConfiguration *config = [QNConfiguration build:^(QNConfigurationBuilder *builder) { - builder.useHttps = NO;// 是否使用https - builder.zone = [QNFixedZone zone0];// 指定华东区域 - // builder.zone = [QNFixedZone zone1];// 指定华北区域 - // builder.zone = [QNFixedZone zone2];// 指定华南区域 - // builder.zone = [QNFixedZone zoneNa0];// 指定北美区域 - // builder.zone = [QNFixedZone zoneAs0];// 指定东南亚区域 + builder.useHttps = YES;// 是否使用https + builder.zone = [[QNAutoZone alloc] init];// 根据 bucket 自动查询区域 + // builder.zone = [QNFixedZone createWithRegionId:@"z0"];// 指定华东区域 + // builder.zone = [QNFixedZone createWithRegionId:@"z1"];// 指定华北区域 + // builder.zone = [QNFixedZone createWithRegionId:@"z2"];// 指定华南区域 + // builder.zone = [QNFixedZone createWithRegionId:@"na0"];// 指定北美区域 + // builder.zone = [QNFixedZone createWithRegionId:@"as0"];// 指定东南亚区域 }]; QNUploadManager *upManager = [[QNUploadManager alloc] initWithConfiguration:config];