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]; }