From dd6e4a1d2e3cae2ed6e089a02a3bfae9449fe8fa Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Wed, 4 Jul 2018 13:32:54 +0800 Subject: [PATCH] Follow App Store submit rule, upgrade the min Xcode version to Xcode 9.0 Using `@available` and `API_AVAILABLE` to check API availability --- .../SDWebImage Demo/LaunchScreen.storyboard | 12 ++++++++---- README.md | 2 +- SDWebImage/SDImageCoderHelper.m | 13 ++++--------- SDWebImage/SDImageIOCoder.m | 19 +++---------------- SDWebImage/SDWebImageCompat.h | 4 ---- SDWebImage/SDWebImageTransition.h | 2 +- 6 files changed, 17 insertions(+), 35 deletions(-) diff --git a/Examples/SDWebImage Demo/LaunchScreen.storyboard b/Examples/SDWebImage Demo/LaunchScreen.storyboard index 66a76819..12baca9e 100644 --- a/Examples/SDWebImage Demo/LaunchScreen.storyboard +++ b/Examples/SDWebImage Demo/LaunchScreen.storyboard @@ -1,8 +1,12 @@ - + + + + - + + @@ -14,9 +18,9 @@ - + - + diff --git a/README.md b/README.md index 92858518..a1dc3ee2 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ This library provides an async image downloader with cache support. For convenie - tvOS 9.0 or later - watchOS 2.0 or later - macOS 10.10 or later -- Xcode 7.3 or later +- Xcode 9.0 or later #### Backwards compatibility diff --git a/SDWebImage/SDImageCoderHelper.m b/SDWebImage/SDImageCoderHelper.m index 6aff85df..a08abf68 100644 --- a/SDWebImage/SDImageCoderHelper.m +++ b/SDWebImage/SDImageCoderHelper.m @@ -203,20 +203,15 @@ static const CGFloat kDestSeemOverlap = 2.0f; // the numbers of pixels to over static CGColorSpaceRef colorSpace; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunguarded-availability" - BOOL shouldUseSRGB = NO; #if SD_UIKIT - NSProcessInfo *processInfo = [NSProcessInfo processInfo]; - shouldUseSRGB = processInfo.operatingSystemVersion.majorVersion >= 9; -#endif - if (shouldUseSRGB) { - // This is what iOS/tvOS device used colorspace, combined with right bitmapInfo, even without decode, can still avoid extra CA::Render::copy_image(which marked `Color Copied Images` from Instruments) + if (@available(iOS 9.0, tvOS 9.0, *)) { colorSpace = CGColorSpaceCreateWithName(kCGColorSpaceSRGB); } else { colorSpace = CGColorSpaceCreateDeviceRGB(); } -#pragma clang diagnostic pop +#else + colorSpace = CGColorSpaceCreateDeviceRGB(); +#endif }); return colorSpace; } diff --git a/SDWebImage/SDImageIOCoder.m b/SDWebImage/SDImageIOCoder.m index 9542fbde..4701f095 100644 --- a/SDWebImage/SDImageIOCoder.m +++ b/SDWebImage/SDImageIOCoder.m @@ -240,28 +240,15 @@ static BOOL canDecode = NO; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunguarded-availability" #if TARGET_OS_SIMULATOR || SD_WATCH canDecode = NO; -#elif SD_MAC - NSProcessInfo *processInfo = [NSProcessInfo processInfo]; - if ([processInfo respondsToSelector:@selector(operatingSystemVersion)]) { - // macOS 10.13+ - canDecode = processInfo.operatingSystemVersion.minorVersion >= 13; - } else { - canDecode = NO; - } -#elif SD_UIKIT - NSProcessInfo *processInfo = [NSProcessInfo processInfo]; - if ([processInfo respondsToSelector:@selector(operatingSystemVersion)]) { - // iOS 11+ && tvOS 11+ - canDecode = processInfo.operatingSystemVersion.majorVersion >= 11; +#else + if (@available(iOS 11.0, tvOS 11.0, macOS 10.13, *)) { + canDecode = YES; } else { canDecode = NO; } #endif -#pragma clang diagnostic pop }); return canDecode; } diff --git a/SDWebImage/SDWebImageCompat.h b/SDWebImage/SDWebImageCompat.h index 6fd79b6b..f47a248a 100644 --- a/SDWebImage/SDWebImageCompat.h +++ b/SDWebImage/SDWebImageCompat.h @@ -63,10 +63,6 @@ #define UIColor NSColor #endif #else - #if __IPHONE_OS_VERSION_MIN_REQUIRED != 20000 && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 - #error SDWebImage doesn't support Deployment Target version < 5.0 - #endif - #if SD_UIKIT #import #endif diff --git a/SDWebImage/SDWebImageTransition.h b/SDWebImage/SDWebImageTransition.h index fcf193f6..e841a962 100644 --- a/SDWebImage/SDWebImageTransition.h +++ b/SDWebImage/SDWebImageTransition.h @@ -41,7 +41,7 @@ typedef void (^SDWebImageTransitionCompletionBlock)(BOOL finished); /** The timing function used for all animations within this transition animation (macOS). */ -@property (nonatomic, strong, nullable) CAMediaTimingFunction *timingFunction NS_AVAILABLE_MAC(10_7); +@property (nonatomic, strong, nullable) CAMediaTimingFunction *timingFunction API_UNAVAILABLE(ios, tvos, watchos); /** A mask of options indicating how you want to perform the animations. */