From 4d3f6d999e58ad847b9ed7e0325e36a44501e116 Mon Sep 17 00:00:00 2001 From: Joey Castillo Date: Thu, 7 Sep 2017 11:52:55 -0400 Subject: [PATCH] add support for tvOS --- YYImage.podspec | 4 +++- YYImage/YYImageCoder.m | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/YYImage.podspec b/YYImage.podspec index 7f76678..a76868b 100644 --- a/YYImage.podspec +++ b/YYImage.podspec @@ -8,6 +8,7 @@ Pod::Spec.new do |s| s.homepage = 'https://github.com/ibireme/YYImage' s.platform = :ios, '6.0' s.ios.deployment_target = '6.0' + s.tvos.deployment_target = "9.0" s.source = { :git => 'https://github.com/ibireme/YYImage.git', :tag => s.version.to_s } s.requires_arc = true @@ -17,7 +18,8 @@ Pod::Spec.new do |s| core.source_files = 'YYImage/*.{h,m}' core.public_header_files = 'YYImage/*.{h}' core.libraries = 'z' - core.frameworks = 'UIKit', 'CoreFoundation', 'QuartzCore', 'AssetsLibrary', 'ImageIO', 'Accelerate', 'MobileCoreServices' + core.tvos.frameworks = 'UIKit', 'CoreFoundation', 'QuartzCore', 'ImageIO', 'Accelerate', 'MobileCoreServices' + core.ios.frameworks = 'UIKit', 'CoreFoundation', 'QuartzCore', 'AssetsLibrary', 'ImageIO', 'Accelerate', 'MobileCoreServices' end s.subspec 'WebP' do |webp| diff --git a/YYImage/YYImageCoder.m b/YYImage/YYImageCoder.m index 66cf46e..3715e48 100644 --- a/YYImage/YYImageCoder.m +++ b/YYImage/YYImageCoder.m @@ -16,7 +16,9 @@ #import #import #import +#if TARGET_OS_IOS #import +#endif #import #import #import @@ -2793,6 +2795,7 @@ - (void)setYy_isDecodedForDisplay:(BOOL)isDecodedForDisplay { } - (void)yy_saveToAlbumWithCompletionBlock:(void(^)(NSURL *assetURL, NSError *error))completionBlock { +#if TARGET_OS_IOS dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSData *data = [self _yy_dataRepresentationForSystem:YES]; ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init]; @@ -2807,8 +2810,11 @@ - (void)yy_saveToAlbumWithCompletionBlock:(void(^)(NSURL *assetURL, NSError *err } }]; }); +#else + NSDictionary *userInfo = @{ NSLocalizedDescriptionKey : @"yy_saveToAlbumWithCompletionBlock failed: operation unavailable on Apple TV." }; + completionBlock(nil, [NSError errorWithDomain:@"com.ibireme.webimage" code:-1 userInfo:userInfo]); +#endif } - - (NSData *)yy_imageDataRepresentation { return [self _yy_dataRepresentationForSystem:NO]; }