Skip to content

Commit

Permalink
iOS support min version to 9.0 (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
YangSen-qn authored Oct 22, 2023
1 parent 3db00f9 commit 32f8709
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 102 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#Changelog
## 8.7.0(2023-10-23)
- iOS 最低版本调整至 iOS9
- QNFixedZone 新增通过 RegionID 构造实例的方法
- 区域查询结果缓存支持磁盘缓存

## 8.6.0(2023-08-07)
- 调整在根据 Bucket 获取其所在区域信息时的主备域名顺序
- 移除亚太-首尔区域
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions Qiniu.podspec
Original file line number Diff line number Diff line change
@@ -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 => [email protected]"
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
Expand Down
10 changes: 6 additions & 4 deletions QiniuSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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)";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion QiniuSDK/Storage/QNUploadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down
4 changes: 2 additions & 2 deletions QiniuSDK/Utils/QNALAssetFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED)
#if !TARGET_OS_MACCATALYST
@class ALAsset;
@interface QNALAssetFile : NSObject <QNFileDelegate>
@interface QNALAssetFile : NSObject <QNFileDelegate>;

/**
* 打开指定文件
Expand All @@ -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
6 changes: 3 additions & 3 deletions QiniuSDK/Utils/QNALAssetFile.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 {
Expand All @@ -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;
}
Expand Down
34 changes: 17 additions & 17 deletions QiniuSDK/Utils/QNMutableArray.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

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

Expand Down Expand Up @@ -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]);
}

Expand All @@ -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]);
}

Expand Down
58 changes: 1 addition & 57 deletions QiniuSDK/Utils/QNSystem.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,63 +15,7 @@
#import <CoreServices/CoreServices.h>
#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) {
Expand Down
2 changes: 1 addition & 1 deletion QiniuSDK/Utils/QNVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
/**
* sdk 版本
*/
static NSString *const kQiniuVersion = @"8.6.0";
static NSString *const kQiniuVersion = @"8.7.0";
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
通过 CocoaPods

```ruby
pod "Qiniu", "~> 8.6.0"
pod "Qiniu", "~> 8.7.0"
```

通过 Swift Package Manager (Xcode 11+)
Expand All @@ -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")
],
// ...
)
Expand All @@ -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 |
Expand Down Expand Up @@ -75,12 +76,13 @@ let package = Package(
#import <QiniuSDK.h>
...
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];
Expand Down

0 comments on commit 32f8709

Please sign in to comment.