From 456bfbac529ba24a1825d7c3458f6f08e7328a9a Mon Sep 17 00:00:00 2001 From: DreamPiggy Date: Wed, 9 Oct 2019 16:09:59 +0800 Subject: [PATCH] Revert the change for APNG constants fix for iOS 8 devices which cause crash, use previous deployment target macro check instead of runtime firmware version check --- SDWebImage/Core/SDImageAPNGCoder.m | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/SDWebImage/Core/SDImageAPNGCoder.m b/SDWebImage/Core/SDImageAPNGCoder.m index 5d2b7321..a0700abb 100644 --- a/SDWebImage/Core/SDImageAPNGCoder.m +++ b/SDWebImage/Core/SDImageAPNGCoder.m @@ -14,20 +14,15 @@ #endif // iOS 8 Image/IO framework binary does not contains these APNG contants, so we define them. Thanks Apple :) -static NSString * kSDCGImagePropertyAPNGLoopCount = @"LoopCount"; -static NSString * kSDCGImagePropertyAPNGDelayTime = @"DelayTime"; -static NSString * kSDCGImagePropertyAPNGUnclampedDelayTime = @"UnclampedDelayTime"; +// We can not use runtime @available check for this issue, because it's a global symbol and should be loaded during launch time by dyld. So hack if the min deployment target version < iOS 9.0, whatever it running on iOS 9+ or not. +#if (__IPHONE_OS_VERSION_MIN_REQUIRED && __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0) +const CFStringRef kCGImagePropertyAPNGLoopCount = (__bridge CFStringRef)@"LoopCount"; +const CFStringRef kCGImagePropertyAPNGDelayTime = (__bridge CFStringRef)@"DelayTime"; +const CFStringRef kCGImagePropertyAPNGUnclampedDelayTime = (__bridge CFStringRef)@"UnclampedDelayTime"; +#endif @implementation SDImageAPNGCoder -+ (void)initialize { - if (@available(iOS 9, *)) { - kSDCGImagePropertyAPNGLoopCount = (__bridge NSString *)kCGImagePropertyAPNGLoopCount; - kSDCGImagePropertyAPNGDelayTime = (__bridge NSString *)kCGImagePropertyAPNGDelayTime; - kSDCGImagePropertyAPNGUnclampedDelayTime = (__bridge NSString *)kCGImagePropertyAPNGUnclampedDelayTime; - } -} - + (instancetype)sharedCoder { static SDImageAPNGCoder *coder; static dispatch_once_t onceToken; @@ -52,15 +47,15 @@ static NSString * kSDCGImagePropertyAPNGUnclampedDelayTime = @"UnclampedDelayTim } + (NSString *)unclampedDelayTimeProperty { - return kSDCGImagePropertyAPNGUnclampedDelayTime; + return (__bridge NSString *)kCGImagePropertyAPNGUnclampedDelayTime; } + (NSString *)delayTimeProperty { - return kSDCGImagePropertyAPNGDelayTime; + return (__bridge NSString *)kCGImagePropertyAPNGDelayTime; } + (NSString *)loopCountProperty { - return kSDCGImagePropertyAPNGLoopCount; + return (__bridge NSString *)kCGImagePropertyAPNGLoopCount; } + (NSUInteger)defaultLoopCount {