Skip to content

Commit 2699c6a

Browse files
authored
Merge pull request #315 from XiaopingSun/versionUpdate
compatibility for mac os
2 parents 8c79a72 + 3217a55 commit 2699c6a

File tree

9 files changed

+42
-28
lines changed

9 files changed

+42
-28
lines changed

QiniuSDK.xcodeproj/xcshareddata/xcschemes/QiniuSDK_Mac.xcscheme

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1100"
3+
LastUpgradeVersion = "1130"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -28,16 +28,6 @@
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
3030
<Testables>
31-
<TestableReference
32-
skipped = "NO">
33-
<BuildableReference
34-
BuildableIdentifier = "primary"
35-
BlueprintIdentifier = "DF2CDE0919DAC05500CE01FB"
36-
BuildableName = "QiniuSDK_MacTests.xctest"
37-
BlueprintName = "QiniuSDK_MacTests"
38-
ReferencedContainer = "container:QiniuSDK.xcodeproj">
39-
</BuildableReference>
40-
</TestableReference>
4131
</Testables>
4232
</TestAction>
4333
<LaunchAction
@@ -66,13 +56,6 @@
6656
ReferencedContainer = "container:QiniuSDK.xcodeproj">
6757
</BuildableReference>
6858
</MacroExpansion>
69-
</LaunchAction>
70-
<ProfileAction
71-
buildConfiguration = "Release"
72-
shouldUseLaunchSchemeArgsEnv = "YES"
73-
savedToolIdentifier = ""
74-
useCustomWorkingDirectory = "NO"
75-
debugDocumentVersioning = "YES">
7659
</ProfileAction>
7760
<AnalyzeAction
7861
buildConfiguration = "Debug">

QiniuSDK/Common/QNALAssetFile.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#import "QNFileDelegate.h"
1212

1313
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED)
14+
#if !TARGET_OS_MACCATALYST
1415
@class ALAsset;
1516
@interface QNALAssetFile : NSObject <QNFileDelegate>
1617

@@ -26,3 +27,4 @@
2627
error:(NSError *__autoreleasing *)error;
2728
@end
2829
#endif
30+
#endif

QiniuSDK/Common/QNALAssetFile.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#import "QNALAssetFile.h"
1010

1111
#ifdef __IPHONE_OS_VERSION_MAX_ALLOWED
12+
#if !TARGET_OS_MACCATALYST
1213
#import <AssetsLibrary/AssetsLibrary.h>
13-
1414
#import "QNResponseInfo.h"
1515

1616
@interface QNALAssetFile ()
@@ -84,3 +84,4 @@ - (int64_t)size {
8484
}
8585
@end
8686
#endif
87+
#endif

QiniuSDK/Common/QNPHAssetFile.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
#import "QNFileDelegate.h"
1212

13-
API_AVAILABLE_BEGIN(macos(10.13), ios(9.1), tvos(10))
13+
API_AVAILABLE_BEGIN(ios(9.1))
14+
API_UNAVAILABLE_BEGIN(macos, tvos)
1415

1516
@class PHAsset;
1617
@interface QNPHAssetFile : NSObject <QNFileDelegate>
@@ -27,3 +28,4 @@ API_AVAILABLE_BEGIN(macos(10.13), ios(9.1), tvos(10))
2728
@end
2829

2930
API_AVAILABLE_END
31+
API_UNAVAILABLE_END

QiniuSDK/Common/QNPHAssetFile.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#import <Photos/Photos.h>
1212
#import "QNResponseInfo.h"
1313

14+
#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 90100)
15+
1416
@interface QNPHAssetFile ()
1517

1618
@property (nonatomic) PHAsset *phAsset;
@@ -180,3 +182,5 @@ - (NSString *)getInfo {
180182
}
181183

182184
@end
185+
186+
#endif

QiniuSDK/Common/QNPHAssetResource.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
#import "QNFileDelegate.h"
1212

13-
API_AVAILABLE_BEGIN(macos(10.15), ios(9), tvos(10))
13+
API_AVAILABLE_BEGIN(ios(9))
14+
API_UNAVAILABLE_BEGIN(macos, tvos)
1415

1516
@class PHAssetResource;
1617

@@ -30,3 +31,4 @@ API_AVAILABLE_BEGIN(macos(10.15), ios(9), tvos(10))
3031
@end
3132

3233
API_AVAILABLE_END
34+
API_UNAVAILABLE_END

QiniuSDK/Common/QNPHAssetResource.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#import <Photos/Photos.h>
1212
#import "QNResponseInfo.h"
1313

14+
#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000)
15+
1416
enum {
1517
kAMASSETMETADATA_PENDINGREADS = 1,
1618
kAMASSETMETADATA_ALLFINISHED = 0
@@ -167,3 +169,5 @@ - (NSData *)fetchDataFromAsset:(PHAssetResource *)videoResource error:(NSError *
167169
}
168170

169171
@end
172+
173+
#endif

QiniuSDK/Storage/QNUploadManager.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@
1313
@class QNResponseInfo;
1414
@class QNUploadOption;
1515
@class QNConfiguration;
16-
@class ALAsset;
1716
@class PHAsset;
1817
@class PHAssetResource;
1918

19+
#if !TARGET_OS_MACCATALYST
20+
@class ALAsset;
21+
#endif
22+
2023
/**
2124
* 上传完成后的回调函数
2225
*
@@ -106,6 +109,7 @@ typedef void (^QNUpCompletionHandler)(QNResponseInfo *info, NSString *key, NSDic
106109
complete:(QNUpCompletionHandler)completionHandler
107110
option:(QNUploadOption *)option;
108111

112+
#if !TARGET_OS_MACCATALYST
109113
/**
110114
* 上传ALAsset文件
111115
*
@@ -119,7 +123,8 @@ typedef void (^QNUpCompletionHandler)(QNResponseInfo *info, NSString *key, NSDic
119123
key:(NSString *)key
120124
token:(NSString *)token
121125
complete:(QNUpCompletionHandler)completionHandler
122-
option:(QNUploadOption *)option;
126+
option:(QNUploadOption *)option API_UNAVAILABLE(macos, tvos);
127+
#endif
123128

124129
/**
125130
* 上传PHAsset文件(IOS8 andLater)
@@ -134,7 +139,7 @@ typedef void (^QNUpCompletionHandler)(QNResponseInfo *info, NSString *key, NSDic
134139
key:(NSString *)key
135140
token:(NSString *)token
136141
complete:(QNUpCompletionHandler)completionHandler
137-
option:(QNUploadOption *)option API_AVAILABLE(macos(10.15), ios(9.1), tvos(10));
142+
option:(QNUploadOption *)option API_AVAILABLE(ios(9.1)) API_UNAVAILABLE(macos, tvos);
138143

139144
/**
140145
* 上传PHAssetResource文件(IOS9.1 andLater)
@@ -150,6 +155,6 @@ typedef void (^QNUpCompletionHandler)(QNResponseInfo *info, NSString *key, NSDic
150155
key:(NSString *)key
151156
token:(NSString *)token
152157
complete:(QNUpCompletionHandler)completionHandler
153-
option:(QNUploadOption *)option API_AVAILABLE(macos(10.15), ios(9), tvos(10));
158+
option:(QNUploadOption *)option API_AVAILABLE(ios(9)) API_UNAVAILABLE(macos, tvos);
154159

155160
@end

QiniuSDK/Storage/QNUploadManager.m

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@
99
#import <Foundation/Foundation.h>
1010

1111
#if __IPHONE_OS_VERSION_MIN_REQUIRED
12-
#import "QNALAssetFile.h"
13-
#import <AssetsLibrary/AssetsLibrary.h>
1412
#import <MobileCoreServices/MobileCoreServices.h>
1513
#import <UIKit/UIKit.h>
1614

15+
#if !TARGET_OS_MACCATALYST
16+
#import <AssetsLibrary/AssetsLibrary.h>
17+
#import "QNALAssetFile.h"
18+
#endif
19+
1720
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
1821
#import "QNPHAssetFile.h"
1922
#import <Photos/Photos.h>
2023
#endif
2124

22-
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 90100
25+
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000
2326
#import "QNPHAssetResource.h"
2427
#endif
2528

@@ -279,11 +282,13 @@ - (void)putFile:(NSString *)filePath
279282
}
280283
}
281284

285+
#if !TARGET_OS_MACCATALYST
282286
- (void)putALAsset:(ALAsset *)asset
283287
key:(NSString *)key
284288
token:(NSString *)token
285289
complete:(QNUpCompletionHandler)completionHandler
286290
option:(QNUploadOption *)option {
291+
#if __IPHONE_OS_VERSION_MIN_REQUIRED
287292
if ([QNUploadManager checkAndNotifyError:key token:token input:asset complete:completionHandler]) {
288293
return;
289294
}
@@ -300,13 +305,16 @@ - (void)putALAsset:(ALAsset *)asset
300305
}
301306
[self putFileInternal:file key:key token:token complete:completionHandler option:option];
302307
}
308+
#endif
303309
}
310+
#endif
304311

305312
- (void)putPHAsset:(PHAsset *)asset
306313
key:(NSString *)key
307314
token:(NSString *)token
308315
complete:(QNUpCompletionHandler)completionHandler
309316
option:(QNUploadOption *)option {
317+
#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 90100)
310318
if ([QNUploadManager checkAndNotifyError:key token:token input:asset complete:completionHandler]) {
311319
return;
312320
}
@@ -323,13 +331,15 @@ - (void)putPHAsset:(PHAsset *)asset
323331
}
324332
[self putFileInternal:file key:key token:token complete:completionHandler option:option];
325333
}
334+
#endif
326335
}
327336

328337
- (void)putPHAssetResource:(PHAssetResource *)assetResource
329338
key:(NSString *)key
330339
token:(NSString *)token
331340
complete:(QNUpCompletionHandler)completionHandler
332341
option:(QNUploadOption *)option {
342+
#if (defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 90000)
333343
if ([QNUploadManager checkAndNotifyError:key token:token input:assetResource complete:completionHandler]) {
334344
return;
335345
}
@@ -345,6 +355,7 @@ - (void)putPHAssetResource:(PHAssetResource *)assetResource
345355
}
346356
[self putFileInternal:file key:key token:token complete:completionHandler option:option];
347357
}
358+
#endif
348359
}
349360

350361
@end

0 commit comments

Comments
 (0)