From 9d9def3dc6f130459dc85704f5fdbc32e0302759 Mon Sep 17 00:00:00 2001 From: Eric Slosser Date: Mon, 21 Nov 2022 16:28:22 -0500 Subject: [PATCH 1/2] switch to FLAnimatedImage, from PINRemoteImage --- CHANGELOG.md | 3 + Examples/Gemfile | 2 +- Examples/Gemfile.lock | 76 ++++++++++---------- Examples/Podfile.lock | 41 +++-------- NYTPhotoViewer.podspec | 3 +- NYTPhotoViewer/NYTPhotoViewController.m | 6 +- NYTPhotoViewer/NYTPhotosViewController.m | 6 +- NYTPhotoViewer/NYTScalingImageView.m | 16 ++--- NYTPhotoViewer/include/NYTScalingImageView.h | 4 +- Package.resolved | 35 ++------- Package.swift | 12 +--- 11 files changed, 76 insertions(+), 128 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c02e07e8..7966b380 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## develop +- fixed SPM problem by switching from PINRemoteImage to FLAnimatedImage + ## [5.0.8](https://github.com/nytimes/NYTPhotoViewer/releases/tag/5.0.8) Changes for users of the library currently on `5.0.8`: diff --git a/Examples/Gemfile b/Examples/Gemfile index 4b39a394..e7fb5699 100644 --- a/Examples/Gemfile +++ b/Examples/Gemfile @@ -1,3 +1,3 @@ source "https://rubygems.org" -gem 'cocoapods', '1.10.0' +gem 'cocoapods', '1.11.3' diff --git a/Examples/Gemfile.lock b/Examples/Gemfile.lock index 5572f7a8..755859a7 100644 --- a/Examples/Gemfile.lock +++ b/Examples/Gemfile.lock @@ -1,23 +1,25 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (3.0.2) - activesupport (5.2.4.4) + CFPropertyList (3.0.5) + rexml + activesupport (6.1.7) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + addressable (2.8.1) + public_suffix (>= 2.0.2, < 6.0) algoliasearch (1.27.5) httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) atomos (0.1.3) - claide (1.0.3) - cocoapods (1.10.0) - addressable (~> 2.6) + claide (1.1.0) + cocoapods (1.11.3) + addressable (~> 2.8) claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.10.0) + cocoapods-core (= 1.11.3) cocoapods-deintegrate (>= 1.0.3, < 2.0) cocoapods-downloader (>= 1.4.0, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0) @@ -28,66 +30,68 @@ GEM escape (~> 0.0.4) fourflusher (>= 2.3.0, < 3.0) gh_inspector (~> 1.0) - molinillo (~> 0.6.6) + molinillo (~> 0.8.0) nap (~> 1.0) - ruby-macho (~> 1.4) - xcodeproj (>= 1.19.0, < 2.0) - cocoapods-core (1.10.0) - activesupport (> 5.0, < 6) - addressable (~> 2.6) + ruby-macho (>= 1.0, < 3.0) + xcodeproj (>= 1.21.0, < 2.0) + cocoapods-core (1.11.3) + activesupport (>= 5.0, < 7) + addressable (~> 2.8) algoliasearch (~> 1.0) concurrent-ruby (~> 1.1) fuzzy_match (~> 2.0.4) nap (~> 1.0) netrc (~> 0.11) - public_suffix + public_suffix (~> 4.0) typhoeus (~> 1.0) - cocoapods-deintegrate (1.0.4) + cocoapods-deintegrate (1.0.5) cocoapods-downloader (1.6.3) cocoapods-plugins (1.0.0) nap - cocoapods-search (1.0.0) - cocoapods-trunk (1.5.0) + cocoapods-search (1.0.1) + cocoapods-trunk (1.6.0) nap (>= 0.8, < 2.0) netrc (~> 0.11) cocoapods-try (1.2.0) colored2 (3.1.2) - concurrent-ruby (1.1.7) + concurrent-ruby (1.1.10) escape (0.0.4) - ethon (0.12.0) - ffi (>= 1.3.0) - ffi (1.13.1) + ethon (0.15.0) + ffi (>= 1.15.0) + ffi (1.15.5) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) httpclient (2.8.3) - i18n (1.8.5) + i18n (1.12.0) concurrent-ruby (~> 1.0) - json (2.3.1) - minitest (5.14.2) - molinillo (0.6.6) + json (2.6.2) + minitest (5.16.3) + molinillo (0.8.0) nanaimo (0.3.0) nap (1.1.0) netrc (0.11.0) - public_suffix (4.0.6) - ruby-macho (1.4.0) - thread_safe (0.3.6) + public_suffix (4.0.7) + rexml (3.2.5) + ruby-macho (2.5.1) typhoeus (1.4.0) ethon (>= 0.9.0) - tzinfo (1.2.10) - thread_safe (~> 0.1) - xcodeproj (1.19.0) + tzinfo (2.0.5) + concurrent-ruby (~> 1.0) + xcodeproj (1.22.0) CFPropertyList (>= 2.3.3, < 4.0) atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) nanaimo (~> 0.3.0) + rexml (~> 3.2.4) + zeitwerk (2.6.1) PLATFORMS ruby DEPENDENCIES - cocoapods (= 1.10.0) + cocoapods (= 1.11.3) BUNDLED WITH 2.1.4 diff --git a/Examples/Podfile.lock b/Examples/Podfile.lock index 251385d4..c5750c52 100644 --- a/Examples/Podfile.lock +++ b/Examples/Podfile.lock @@ -1,28 +1,13 @@ PODS: - - NYTPhotoViewer (5.0.7): - - NYTPhotoViewer/AnimatedGifSupport (= 5.0.7) - - NYTPhotoViewer/Core (= 5.0.7) - - NYTPhotoViewer/AnimatedGifSupport (5.0.7): + - FLAnimatedImage (1.0.17) + - NYTPhotoViewer (5.0.8): + - NYTPhotoViewer/AnimatedGifSupport (= 5.0.8) + - NYTPhotoViewer/Core (= 5.0.8) + - NYTPhotoViewer/AnimatedGifSupport (5.0.8): + - FLAnimatedImage - NYTPhotoViewer/Core - - PINRemoteImage/iOS - - PINRemoteImage/PINCache - - NYTPhotoViewer/Core (5.0.7) + - NYTPhotoViewer/Core (5.0.8) - OCMock (3.7.1) - - PINCache (3.0.3): - - PINCache/Arc-exception-safe (= 3.0.3) - - PINCache/Core (= 3.0.3) - - PINCache/Arc-exception-safe (3.0.3): - - PINCache/Core - - PINCache/Core (3.0.3): - - PINOperation (~> 1.2.1) - - PINOperation (1.2.1) - - PINRemoteImage/Core (3.0.3): - - PINOperation - - PINRemoteImage/iOS (3.0.3): - - PINRemoteImage/Core - - PINRemoteImage/PINCache (3.0.3): - - PINCache (~> 3.0.3) - - PINRemoteImage/Core DEPENDENCIES: - NYTPhotoViewer (from `..`) @@ -30,22 +15,18 @@ DEPENDENCIES: SPEC REPOS: trunk: + - FLAnimatedImage - OCMock - - PINCache - - PINOperation - - PINRemoteImage EXTERNAL SOURCES: NYTPhotoViewer: :path: ".." SPEC CHECKSUMS: - NYTPhotoViewer: 64f9c45438a0e6a8f6fa67fd924bd090dea54ad4 + FLAnimatedImage: bbf914596368867157cc71b38a8ec834b3eeb32b + NYTPhotoViewer: 56bb5fd5c90524ef2e8bd23e660440934bc5764d OCMock: 75fbeaa46a9b11f8c182bbb1d1f7e9a35ccc9955 - PINCache: 7a8fc1a691173d21dbddbf86cd515de6efa55086 - PINOperation: 00c935935f1e8cf0d1e2d6b542e75b88fc3e5e20 - PINRemoteImage: f1295b29f8c5e640e25335a1b2bd9d805171bd01 PODFILE CHECKSUM: 2d91d58ac59e8440027da7c7b8b5f2e362fb3857 -COCOAPODS: 1.10.0 +COCOAPODS: 1.11.3 diff --git a/NYTPhotoViewer.podspec b/NYTPhotoViewer.podspec index 786240a8..bfdc5405 100644 --- a/NYTPhotoViewer.podspec +++ b/NYTPhotoViewer.podspec @@ -24,8 +24,7 @@ Pod::Spec.new do |s| s.subspec 'AnimatedGifSupport' do |ss| ss.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'ANIMATED_GIF_SUPPORT=1' } ss.dependency 'NYTPhotoViewer/Core' - ss.dependency 'PINRemoteImage/iOS' - ss.dependency 'PINRemoteImage/PINCache' + ss.dependency 'FLAnimatedImage' end end diff --git a/NYTPhotoViewer/NYTPhotoViewController.m b/NYTPhotoViewer/NYTPhotoViewController.m index be43d3b0..7e7d051c 100644 --- a/NYTPhotoViewer/NYTPhotoViewController.m +++ b/NYTPhotoViewer/NYTPhotoViewController.m @@ -12,11 +12,9 @@ #ifdef ANIMATED_GIF_SUPPORT #if SWIFT_PACKAGE - #import "PINRemoteImage.h" - #import "PINAnimatedImageView.h" + #import "FLAnimatedImageView.h" #else - #import - #import + #import #endif #endif diff --git a/NYTPhotoViewer/NYTPhotosViewController.m b/NYTPhotoViewer/NYTPhotosViewController.m index 9420a768..9f28bc37 100644 --- a/NYTPhotoViewer/NYTPhotosViewController.m +++ b/NYTPhotoViewer/NYTPhotosViewController.m @@ -21,11 +21,9 @@ #ifdef ANIMATED_GIF_SUPPORT #if SWIFT_PACKAGE - #import "PINRemoteImage.h" - #import "PINAnimatedImageView.h" + #import "FLAnimatedImageView.h" #else - #import - #import + #import #endif #endif diff --git a/NYTPhotoViewer/NYTScalingImageView.m b/NYTPhotoViewer/NYTScalingImageView.m index 0a0c6f71..17815137 100644 --- a/NYTPhotoViewer/NYTScalingImageView.m +++ b/NYTPhotoViewer/NYTScalingImageView.m @@ -12,11 +12,10 @@ #ifdef ANIMATED_GIF_SUPPORT #if SWIFT_PACKAGE - #import "PINRemoteImage.h" - #import "PINAnimatedImageView.h" + #import "FLAnimatedImageView.h" #else - #import - #import + #import + #import #endif #endif @@ -25,7 +24,7 @@ @interface NYTScalingImageView () - (instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER; #ifdef ANIMATED_GIF_SUPPORT -@property (nonatomic) PINAnimatedImageView *imageView; +@property (nonatomic) FLAnimatedImageView *imageView; #else @property (nonatomic) UIImageView *imageView; #endif @@ -94,7 +93,8 @@ - (void)setupInternalImageViewWithImage:(UIImage *)image imageData:(NSData *)ima UIImage *imageToUse = image ?: [UIImage imageWithData:imageData]; #ifdef ANIMATED_GIF_SUPPORT - self.imageView = [[PINAnimatedImageView alloc] initWithAnimatedImage:[[PINCachedAnimatedImage alloc] initWithAnimatedImageData:imageData]]; + self.imageView = FLAnimatedImageView.new; + self.imageView.animatedImage = [FLAnimatedImage animatedImageWithGIFData:imageData]; #else self.imageView = [[UIImageView alloc] initWithImage:imageToUse]; #endif @@ -127,8 +127,8 @@ - (void)updateImage:(UIImage *)image imageData:(NSData *)imageData { self.imageView.image = imageToUse; #ifdef ANIMATED_GIF_SUPPORT - // It's necessarry to first assign the UIImage so calulations for layout go right (see above) - self.imageView.animatedImage = [[PINCachedAnimatedImage alloc] initWithAnimatedImageData:imageData]; + // It's necessary to first assign the UIImage so calculations for layout go right (see above) + self.imageView.animatedImage = [FLAnimatedImage animatedImageWithGIFData:imageData]; #endif self.imageView.frame = CGRectMake(0, 0, imageToUse.size.width, imageToUse.size.height); diff --git a/NYTPhotoViewer/include/NYTScalingImageView.h b/NYTPhotoViewer/include/NYTScalingImageView.h index 06cdd5e1..daf4ffba 100644 --- a/NYTPhotoViewer/include/NYTScalingImageView.h +++ b/NYTPhotoViewer/include/NYTScalingImageView.h @@ -9,7 +9,7 @@ @import UIKit; #ifdef ANIMATED_GIF_SUPPORT -@class PINAnimatedImageView; +@class FLAnimatedImageView; #endif NS_ASSUME_NONNULL_BEGIN @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN * The image view used internally as the contents of the scroll view. */ #ifdef ANIMATED_GIF_SUPPORT -@property (nonatomic, readonly) PINAnimatedImageView *imageView; +@property (nonatomic, readonly) FLAnimatedImageView *imageView; #else @property (nonatomic, readonly) UIImageView *imageView; #endif diff --git a/Package.resolved b/Package.resolved index 689f4bcd..36d9b989 100644 --- a/Package.resolved +++ b/Package.resolved @@ -2,39 +2,12 @@ "object": { "pins": [ { - "package": "libwebp", - "repositoryURL": "https://github.com/SDWebImage/libwebp-Xcode", + "package": "FLAnimatedImage", + "repositoryURL": "https://github.com/Flipboard/FLAnimatedImage.git", "state": { "branch": null, - "revision": "86c1b5d567ed548da861486b54e1f8f068a3cef7", - "version": "1.1.0" - } - }, - { - "package": "PINCache", - "repositoryURL": "https://github.com/pinterest/PINCache.git", - "state": { - "branch": null, - "revision": "875c654984fb52b47ca65ae70d24852b0003ccd9", - "version": "3.0.3" - } - }, - { - "package": "PINOperation", - "repositoryURL": "https://github.com/pinterest/PINOperation.git", - "state": { - "branch": null, - "revision": "44d8ca154a4e75a028a5548c31ff3a53b90cef15", - "version": "1.2.1" - } - }, - { - "package": "PINRemoteImage", - "repositoryURL": "https://github.com/pinterest/PINRemoteImage.git", - "state": { - "branch": null, - "revision": "611d8ab1c6937bcdfd9d59a967716b0370a332be", - "version": "3.0.3" + "revision": "d4f07b6f164d53c1212c3e54d6460738b1981e9f", + "version": "1.0.17" } } ] diff --git a/Package.swift b/Package.swift index 1c2ccb5f..97f3f47a 100644 --- a/Package.swift +++ b/Package.swift @@ -9,24 +9,16 @@ let package = Package( products: [ .library( name: "NYTPhotoViewer", - targets: ["NYTPhotoViewer", "NYTPhotoViewerGIF"] + targets: ["NYTPhotoViewer"] ), ], dependencies: [ - .package(url: "https://github.com/pinterest/PINRemoteImage.git", from: "3.0.1") + .package(url: "https://github.com/Flipboard/FLAnimatedImage.git", .upToNextMajor(from: "1.0.17")) ], targets: [ .target( name: "NYTPhotoViewer", path: "NYTPhotoViewer" ), - .target( - name: "NYTPhotoViewerGIF", - dependencies: ["PINRemoteImage"], - path: "SourceSymLink", - cSettings: [ - .define("ANIMATED_GIF_SUPPORT", to: "1") - ] - ) ] ) From 52c4973c292840bf702dc14b1f352edd172aca9e Mon Sep 17 00:00:00 2001 From: Zev Eisenberg Date: Wed, 4 Jan 2023 14:45:47 -0500 Subject: [PATCH 2/2] Fix tests. --- UnitTests/NYTScalingImageViewTests.m | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/UnitTests/NYTScalingImageViewTests.m b/UnitTests/NYTScalingImageViewTests.m index 37e1f0e2..14f60280 100644 --- a/UnitTests/NYTScalingImageViewTests.m +++ b/UnitTests/NYTScalingImageViewTests.m @@ -10,8 +10,7 @@ @import XCTest; #import -#import -#import +@import FLAnimatedImage; @interface NYTScalingImageViewTests : XCTestCase @@ -68,7 +67,7 @@ - (void)testImageInitializationSetsImage { - (void)testDataInitializationSetsImage { NYTScalingImageView *scalingImageView = [[NYTScalingImageView alloc] initWithImageData:self.imageData frame:CGRectZero]; - XCTAssertEqual(self.imageData, ((PINAnimatedImageView *)scalingImageView.imageView).animatedImage.data); + XCTAssertEqual(self.imageData, scalingImageView.imageView.animatedImage.data); } - (void)testUpdateImageUpdatesImage { @@ -85,13 +84,13 @@ - (void)testUpdateImageDataUpdatesImage { NYTScalingImageView *scalingImageView = [[NYTScalingImageView alloc] initWithImageData:self.imageData frame:CGRectZero]; [scalingImageView updateImageData:image2]; - XCTAssertEqual(image2, ((PINAnimatedImageView *)scalingImageView.imageView).animatedImage.data); + XCTAssertEqual(image2, scalingImageView.imageView.animatedImage.data); } - (void)testImageViewIsOfCorrectKindAfterInitialization { NYTScalingImageView *scalingImageViewer = [[NYTScalingImageView alloc] initWithImageData:self.imageData frame:CGRectZero]; - XCTAssertTrue([scalingImageViewer.imageView isKindOfClass:PINAnimatedImageView.class]); + XCTAssertTrue([scalingImageViewer.imageView isKindOfClass:FLAnimatedImageView.class]); } @end