From 677d77d8bb7741f34a72cd466e519c2274cbb325 Mon Sep 17 00:00:00 2001 From: Alex Vaiman Date: Mon, 19 Feb 2024 10:48:38 +0200 Subject: [PATCH 01/15] reducePriorityOnDisappear, flag to reduce download task priority on cell disappearing. --- Sources/SwiftUI/ImageBinder.swift | 6 ++++++ Sources/SwiftUI/ImageContext.swift | 1 + Sources/SwiftUI/KFImageOptions.swift | 9 +++++++++ Sources/SwiftUI/KFImageRenderer.swift | 6 ++++++ 4 files changed, 22 insertions(+) diff --git a/Sources/SwiftUI/ImageBinder.swift b/Sources/SwiftUI/ImageBinder.swift index 7ad5f2c92..f2042f0ed 100644 --- a/Sources/SwiftUI/ImageBinder.swift +++ b/Sources/SwiftUI/ImageBinder.swift @@ -144,6 +144,12 @@ extension KFImage { downloadTask = nil loading = false } + + /// Reduce the download task priority if it is in progress. + func reducePriorityOnDisappear() { + guard let downloadTask = downloadTask, loading == true else { return } + downloadTask.sessionTask.task.priority = URLSessionTask.lowPriority + } } } #endif diff --git a/Sources/SwiftUI/ImageContext.swift b/Sources/SwiftUI/ImageContext.swift index 91d3b4341..7fd42931b 100644 --- a/Sources/SwiftUI/ImageContext.swift +++ b/Sources/SwiftUI/ImageContext.swift @@ -41,6 +41,7 @@ extension KFImage { var contentConfiguration: ((HoldingView) -> AnyView)? = nil var cancelOnDisappear: Bool = false + var reducePriorityOnDisappear: Bool = false var placeholder: ((Progress) -> AnyView)? = nil let onFailureDelegate = Delegate() diff --git a/Sources/SwiftUI/KFImageOptions.swift b/Sources/SwiftUI/KFImageOptions.swift index a63d90976..afaab459f 100644 --- a/Sources/SwiftUI/KFImageOptions.swift +++ b/Sources/SwiftUI/KFImageOptions.swift @@ -121,6 +121,15 @@ extension KFImageProtocol { context.cancelOnDisappear = flag return self } + + /// Sets reduce priority of the download task to low, bound to `self` when the view disappearing. + /// - Parameter flag: Whether reduce the priority task or not. + /// - Returns: A `KFImage` view that reduces downloading task priority when disappears. + public func reducePriorityOnDisappear(_ flag: Bool) -> Self { + context.reducePriorityOnDisappear = flag + return self + } + /// Sets a fade transition for the image task. /// - Parameter duration: The duration of the fade transition. diff --git a/Sources/SwiftUI/KFImageRenderer.swift b/Sources/SwiftUI/KFImageRenderer.swift index 5203b4ed8..6baaf5626 100644 --- a/Sources/SwiftUI/KFImageRenderer.swift +++ b/Sources/SwiftUI/KFImageRenderer.swift @@ -58,6 +58,10 @@ struct KFImageRenderer : View where HoldingView: KFImageHoldingView } if !binder.loadingOrSucceeded { binder.start(context: context) + } else { + if context.reducePriorityOnDisappear { + binder.downloadTask?.sessionTask.task.priority = URLSessionTask.defaultPriority + } } } .onDisappear { [weak binder = self.binder] in @@ -66,6 +70,8 @@ struct KFImageRenderer : View where HoldingView: KFImageHoldingView } if context.cancelOnDisappear { binder.cancel() + } else if context.reducePriorityOnDisappear { + binder.reducePriorityOnDisappear() } } } From df8c264c41a05b1b5129687499666e3691f39c7e Mon Sep 17 00:00:00 2001 From: Alex Vaiman Date: Mon, 19 Feb 2024 11:12:13 +0200 Subject: [PATCH 02/15] Refactor to modify the task from the binder instead of directly from KFImageRenderer, aligning with the rest of the code style. --- Sources/SwiftUI/ImageBinder.swift | 6 ++++++ Sources/SwiftUI/KFImageRenderer.swift | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/SwiftUI/ImageBinder.swift b/Sources/SwiftUI/ImageBinder.swift index f2042f0ed..2a7fb7155 100644 --- a/Sources/SwiftUI/ImageBinder.swift +++ b/Sources/SwiftUI/ImageBinder.swift @@ -145,6 +145,12 @@ extension KFImage { loading = false } + /// Restores the download task priority to default if it is in progress. + func restorePriorityOnAppear() { + guard let downloadTask = downloadTask, loading == true else { return } + downloadTask.sessionTask.task.priority = URLSessionTask.defaultPriority + } + /// Reduce the download task priority if it is in progress. func reducePriorityOnDisappear() { guard let downloadTask = downloadTask, loading == true else { return } diff --git a/Sources/SwiftUI/KFImageRenderer.swift b/Sources/SwiftUI/KFImageRenderer.swift index 6baaf5626..e526e8aaa 100644 --- a/Sources/SwiftUI/KFImageRenderer.swift +++ b/Sources/SwiftUI/KFImageRenderer.swift @@ -60,7 +60,7 @@ struct KFImageRenderer : View where HoldingView: KFImageHoldingView binder.start(context: context) } else { if context.reducePriorityOnDisappear { - binder.downloadTask?.sessionTask.task.priority = URLSessionTask.defaultPriority + binder.restorePriorityOnAppear() } } } From 76d8923138def631825a519157eee742ffa32f02 Mon Sep 17 00:00:00 2001 From: nuomi1 Date: Wed, 17 Apr 2024 20:25:26 +0800 Subject: [PATCH 03/15] feat: add PHPickerResultImageDataProvider --- Kingfisher.xcodeproj/project.pbxproj | 4 + .../PHPickerResultImageDataProvider.swift | 81 +++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 Sources/General/ImageSource/PHPickerResultImageDataProvider.swift diff --git a/Kingfisher.xcodeproj/project.pbxproj b/Kingfisher.xcodeproj/project.pbxproj index 941ee8615..04c40fd0c 100644 --- a/Kingfisher.xcodeproj/project.pbxproj +++ b/Kingfisher.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 07292245263B02F00089E810 /* KFAnimatedImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 07292244263B02F00089E810 /* KFAnimatedImage.swift */; }; + 078DCB4F2BCFEB7D0008114E /* PHPickerResultImageDataProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 078DCB4E2BCFEB7D0008114E /* PHPickerResultImageDataProvider.swift */; }; 22FDCE0E2700078B0044D11E /* CPListItem+Kingfisher.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22FDCE0D2700078B0044D11E /* CPListItem+Kingfisher.swift */; }; 388F37382B4D9CDB0089705C /* DisplayLink.swift in Sources */ = {isa = PBXBuildFile; fileRef = 388F37372B4D9CDB0089705C /* DisplayLink.swift */; }; 4B10480D216F157000300C61 /* ImageDataProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B10480C216F157000300C61 /* ImageDataProcessor.swift */; }; @@ -148,6 +149,7 @@ /* Begin PBXFileReference section */ 07292244263B02F00089E810 /* KFAnimatedImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KFAnimatedImage.swift; sourceTree = ""; }; + 078DCB4E2BCFEB7D0008114E /* PHPickerResultImageDataProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PHPickerResultImageDataProvider.swift; sourceTree = ""; }; 185218B51CC07F8300BD58DE /* NSButtonExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSButtonExtensionTests.swift; sourceTree = ""; }; 22FDCE0D2700078B0044D11E /* CPListItem+Kingfisher.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CPListItem+Kingfisher.swift"; sourceTree = ""; }; 388F37372B4D9CDB0089705C /* DisplayLink.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DisplayLink.swift; sourceTree = ""; }; @@ -655,6 +657,7 @@ D12AB69E215D2BB50013BA68 /* Resource.swift */, D1E56444219B16330057AAE3 /* ImageDataProvider.swift */, D16CC3D524E02E9500F1A515 /* AVAssetImageDataProvider.swift */, + 078DCB4E2BCFEB7D0008114E /* PHPickerResultImageDataProvider.swift */, ); path = ImageSource; sourceTree = ""; @@ -850,6 +853,7 @@ D12AB714215D2BB50013BA68 /* ImageCache.swift in Sources */, 4B88CEB02646C056009EBB41 /* KFImageProtocol.swift in Sources */, D12AB6D0215D2BB50013BA68 /* ImagePrefetcher.swift in Sources */, + 078DCB4F2BCFEB7D0008114E /* PHPickerResultImageDataProvider.swift in Sources */, 388F37382B4D9CDB0089705C /* DisplayLink.swift in Sources */, D12AB6F4215D2BB50013BA68 /* ImageView+Kingfisher.swift in Sources */, D12AB6FC215D2BB50013BA68 /* UIButton+Kingfisher.swift in Sources */, diff --git a/Sources/General/ImageSource/PHPickerResultImageDataProvider.swift b/Sources/General/ImageSource/PHPickerResultImageDataProvider.swift new file mode 100644 index 000000000..862211fbb --- /dev/null +++ b/Sources/General/ImageSource/PHPickerResultImageDataProvider.swift @@ -0,0 +1,81 @@ +// +// PHPickerResultImageDataProvider.swift +// Kingfisher +// +// Created by nuomi1 on 2024-04-17. +// +// Copyright (c) 2024 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation +import PhotosUI + +/// A data provider to provide image data from a given `PHPickerResult`. +@available(iOS 14.0, macOS 13.0, *) +@available(watchOS, unavailable) +@available(tvOS, unavailable) +public struct PHPickerResultImageDataProvider: ImageDataProvider { + + /// The possible error might be caused by the `PHPickerResultImageDataProvider`. + /// - invalidImage: The retrieved image is invalid. + public enum PHPickerResultImageDataProviderError: Error { + /// The retrieved image is invalid. + case invalidImage + } + + /// The picker result bound to `self`. + public let pickerResult: PHPickerResult + + /// The content type of the image. + public let contentType: UTType + + private var internalKey: String { + pickerResult.assetIdentifier ?? UUID().uuidString + } + + public var cacheKey: String { + "\(internalKey)_\(contentType.identifier)" + } + + /// Creates an image data provider from a given `PHPickerResult`. + /// - Parameters: + /// - pickerResult: The picker result to provide image data. + /// - contentType: The content type of the image. Default is `UTType.image`. + public init(pickerResult: PHPickerResult, contentType: UTType = UTType.image) { + self.pickerResult = pickerResult + self.contentType = contentType + } + + public func data(handler: @escaping (Result) -> Void) { + pickerResult.itemProvider.loadDataRepresentation(forTypeIdentifier: contentType.identifier) { data, error in + if let error { + handler(.failure(error)) + return + } + + guard let data else { + handler(.failure(PHPickerResultImageDataProviderError.invalidImage)) + return + } + + handler(.success(data)) + } + } +} From 48a701985e12f3f65c297a3ec6eb68bf833e968c Mon Sep 17 00:00:00 2001 From: nuomi1 Date: Wed, 17 Apr 2024 20:25:40 +0800 Subject: [PATCH 04/15] feat: add PHPickerResultViewController --- .../Base.lproj/Main.storyboard | 73 ++++++++++++++++++- .../PHPickerResultViewController.swift | 69 ++++++++++++++++++ .../Kingfisher-Demo.xcodeproj/project.pbxproj | 4 + 3 files changed, 143 insertions(+), 3 deletions(-) create mode 100644 Demo/Demo/Kingfisher-Demo/ViewControllers/PHPickerResultViewController.swift diff --git a/Demo/Demo/Kingfisher-Demo/Base.lproj/Main.storyboard b/Demo/Demo/Kingfisher-Demo/Base.lproj/Main.storyboard index d6324938e..2af261af5 100644 --- a/Demo/Demo/Kingfisher-Demo/Base.lproj/Main.storyboard +++ b/Demo/Demo/Kingfisher-Demo/Base.lproj/Main.storyboard @@ -1,9 +1,9 @@ - + - + @@ -467,9 +467,33 @@ - + + + + + + + + + + + + + + + + + + + + @@ -1127,6 +1151,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Demo/Demo/Kingfisher-Demo/ViewControllers/PHPickerResultViewController.swift b/Demo/Demo/Kingfisher-Demo/ViewControllers/PHPickerResultViewController.swift new file mode 100644 index 000000000..18f9c7fd1 --- /dev/null +++ b/Demo/Demo/Kingfisher-Demo/ViewControllers/PHPickerResultViewController.swift @@ -0,0 +1,69 @@ +// +// PHPickerResultViewController.swift +// Kingfisher +// +// Created by nuomi1 on 2024-04-17. +// +// Copyright (c) 2024 Wei Wang +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation +import Kingfisher +import PhotosUI +import UIKit + +class PHPickerResultViewController: UIViewController { + @IBOutlet var imageView: UIImageView! + + @IBAction func onTapButton() { + if #available(iOS 14.0, *) { + presentPickerViewController() + } else { + presentAlertController() + } + } + + private func presentAlertController() { + let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) + let alertController = UIAlertController(title: "Warning!", message: "Only supports iOS 14+", preferredStyle: .alert) + alertController.addAction(cancelAction) + present(alertController, animated: true) + } + + @available(iOS 14.0, *) + private func presentPickerViewController() { + var configuration = PHPickerConfiguration(photoLibrary: .shared()) + configuration.filter = .images + configuration.selectionLimit = 1 + let viewController = PHPickerViewController(configuration: configuration) + viewController.delegate = self + present(viewController, animated: true) + } +} + +@available(iOS 14, *) +extension PHPickerResultViewController: PHPickerViewControllerDelegate { + public func picker(_ picker: PHPickerViewController, didFinishPicking results: [PHPickerResult]) { + picker.dismiss(animated: true) + guard let result = results.first else { return } + let provider = PHPickerResultImageDataProvider(pickerResult: result) + imageView.kf.setImage(with: .provider(provider)) + } +} diff --git a/Demo/Kingfisher-Demo.xcodeproj/project.pbxproj b/Demo/Kingfisher-Demo.xcodeproj/project.pbxproj index 54ea6afe7..7cb5dec23 100644 --- a/Demo/Kingfisher-Demo.xcodeproj/project.pbxproj +++ b/Demo/Kingfisher-Demo.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 072922432638639D0089E810 /* AnimatedImageDemo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 072922422638639D0089E810 /* AnimatedImageDemo.swift */; }; + 078DCB512BCFEFB40008114E /* PHPickerResultViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 078DCB502BCFEFB40008114E /* PHPickerResultViewController.swift */; }; 277EAE8D2045B39C00547CD3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 277EAE892045B39C00547CD3 /* Assets.xcassets */; }; 277EAE8E2045B39C00547CD3 /* Interface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 277EAE8A2045B39C00547CD3 /* Interface.storyboard */; }; 277EAE9D2045B4D500547CD3 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 277EAE962045B4D500547CD3 /* Assets.xcassets */; }; @@ -156,6 +157,7 @@ /* Begin PBXFileReference section */ 072922422638639D0089E810 /* AnimatedImageDemo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnimatedImageDemo.swift; sourceTree = ""; }; + 078DCB502BCFEFB40008114E /* PHPickerResultViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PHPickerResultViewController.swift; sourceTree = ""; }; 277EAE892045B39C00547CD3 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 277EAE8B2045B39C00547CD3 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Interface.storyboard; sourceTree = ""; }; 277EAE8C2045B39C00547CD3 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -398,6 +400,7 @@ C959EEE522874DC600467A10 /* ProgressiveJPEGViewController.swift */, D12EB83D24DD902300329EE1 /* TextAttachmentViewController.swift */, D16CC3D724E03FEA00F1A515 /* AVAssetImageGeneratorViewController.swift */, + 078DCB502BCFEFB40008114E /* PHPickerResultViewController.swift */, D1F78A5E2589F0AA00930759 /* SwiftUIViewController.swift */, ); path = ViewControllers; @@ -721,6 +724,7 @@ D1F06F3321AA4292000B1C38 /* DetailImageViewController.swift in Sources */, D198F42225EDC4B900C53E0D /* GridDemo.swift in Sources */, 4B1C7A3D21A256E300CE9D31 /* InfinityCollectionViewController.swift in Sources */, + 078DCB512BCFEFB40008114E /* PHPickerResultViewController.swift in Sources */, D1A1CCA321A1879600263AD8 /* MainViewController.swift in Sources */, 4BC0ED4A29A6EE78003E9CD1 /* Issue2035View.swift in Sources */, D1F06F3721AAEACF000B1C38 /* GIFViewController.swift in Sources */, From 62cd8d7949aabe28f5d645aa83679a83d8b4d7c7 Mon Sep 17 00:00:00 2001 From: HolidayBomb Date: Thu, 16 May 2024 15:21:40 +0800 Subject: [PATCH 05/15] Fix the issue where UsesHashedFileNameWithAutoExtAndProcessor does not retrieve the correct file extension. --- Sources/Utility/String+MD5.swift | 15 ++++++++------- Tests/KingfisherTests/DiskStorageTests.swift | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Sources/Utility/String+MD5.swift b/Sources/Utility/String+MD5.swift index 59586b5c1..dd702805f 100644 --- a/Sources/Utility/String+MD5.swift +++ b/Sources/Utility/String+MD5.swift @@ -49,15 +49,16 @@ extension KingfisherWrapper where Base == String { } var ext: String? { - var ext = "" - if let index = base.lastIndex(of: ".") { - let extRange = base.index(index, offsetBy: 1).. 0 ? String(firstSeg) : nil + + var ext = "" + if let index = firstSeg.lastIndex(of: ".") { + let extRange = firstSeg.index(index, offsetBy: 1).. 0 ? ext : nil } } diff --git a/Tests/KingfisherTests/DiskStorageTests.swift b/Tests/KingfisherTests/DiskStorageTests.swift index 21995f266..51e68f0cf 100644 --- a/Tests/KingfisherTests/DiskStorageTests.swift +++ b/Tests/KingfisherTests/DiskStorageTests.swift @@ -213,7 +213,7 @@ class DiskStorageTests: XCTestCase { func testConfigUsesHashedFileNameWithAutoExtAndProcessor() { // The key of an image with processor will be as this format. - let key = "test.jpeg@abc" + let key = "test.jpeg@com.onevcat.Kingfisher.DownsamplingImageProcessor" // hashed fileName storage.config.usesHashedFileName = true From f7eb024904738ebd1becc56fdac690ae865e5e64 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 16 May 2024 21:11:50 +0000 Subject: [PATCH 06/15] Bump rexml from 3.2.6 to 3.2.8 Bumps [rexml](https://github.com/ruby/rexml) from 3.2.6 to 3.2.8. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](https://github.com/ruby/rexml/compare/v3.2.6...v3.2.8) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] --- Gemfile.lock | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6de3ecb17..dd684a517 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -238,7 +238,8 @@ GEM trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) retriable (3.1.2) - rexml (3.2.6) + rexml (3.2.8) + strscan (>= 3.0.9) rouge (2.0.7) ruby-macho (2.5.1) ruby2_keywords (0.0.5) @@ -252,6 +253,7 @@ GEM simctl (1.6.10) CFPropertyList naturally + strscan (3.1.0) terminal-notifier (2.0.0) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) From 3d29feed7b1922ffd050aa7279b25430e1b98e39 Mon Sep 17 00:00:00 2001 From: onevcat Date: Sun, 2 Jun 2024 15:52:31 +0900 Subject: [PATCH 07/15] Do not use ruby setup --- .github/workflows/build.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index c093458d0..411db9840 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -19,10 +19,8 @@ jobs: ] steps: - uses: actions/checkout@v4 - - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - self-hosted: true + - name: Install Gems + run: bundle install - name: Run tests env: DESTINATION: platform=${{ matrix.destination }} From 12a82d271cdf8a77737dd51efbee70e8b355adf1 Mon Sep 17 00:00:00 2001 From: onevcat Date: Sun, 2 Jun 2024 15:53:42 +0900 Subject: [PATCH 08/15] Update ruby version --- .ruby-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ruby-version b/.ruby-version index 15a279981..bea438e9a 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.3.0 +3.3.1 From 44d337b9777b0c0390249a666fdd9f440468b437 Mon Sep 17 00:00:00 2001 From: onevcat Date: Sun, 2 Jun 2024 15:50:45 +0900 Subject: [PATCH 09/15] Update xcode versions --- .github/workflows/build.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 411db9840..ab3a90711 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -14,8 +14,8 @@ jobs: 'watchOS Simulator,name=Apple Watch Series 8 (41mm)' ] xcode: [ - '15.2', - '15.3' + '15.3', + '15.4' ] steps: - uses: actions/checkout@v4 From 786efb21badb61423c947432e1910ad13cd4ae28 Mon Sep 17 00:00:00 2001 From: onevcat Date: Sun, 9 Jun 2024 20:59:13 +0900 Subject: [PATCH 10/15] Only allow iOS and macOS --- .../ImageSource/PHPickerResultImageDataProvider.swift | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Sources/General/ImageSource/PHPickerResultImageDataProvider.swift b/Sources/General/ImageSource/PHPickerResultImageDataProvider.swift index 862211fbb..693443173 100644 --- a/Sources/General/ImageSource/PHPickerResultImageDataProvider.swift +++ b/Sources/General/ImageSource/PHPickerResultImageDataProvider.swift @@ -25,12 +25,13 @@ // THE SOFTWARE. import Foundation + +#if os(iOS) || os(macOS) + import PhotosUI /// A data provider to provide image data from a given `PHPickerResult`. @available(iOS 14.0, macOS 13.0, *) -@available(watchOS, unavailable) -@available(tvOS, unavailable) public struct PHPickerResultImageDataProvider: ImageDataProvider { /// The possible error might be caused by the `PHPickerResultImageDataProvider`. @@ -79,3 +80,5 @@ public struct PHPickerResultImageDataProvider: ImageDataProvider { } } } + +#endif From 62b5fcca4757599d1c876488799f4d7e146cede9 Mon Sep 17 00:00:00 2001 From: onevcat Date: Sun, 9 Jun 2024 22:51:49 +0900 Subject: [PATCH 11/15] Add visionOS as supported platform --- .../General/ImageSource/PHPickerResultImageDataProvider.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/General/ImageSource/PHPickerResultImageDataProvider.swift b/Sources/General/ImageSource/PHPickerResultImageDataProvider.swift index 693443173..c743a10af 100644 --- a/Sources/General/ImageSource/PHPickerResultImageDataProvider.swift +++ b/Sources/General/ImageSource/PHPickerResultImageDataProvider.swift @@ -26,7 +26,7 @@ import Foundation -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import PhotosUI From 34ef37ca838c92376741638a059f3b6b9721c0dd Mon Sep 17 00:00:00 2001 From: onevcat Date: Mon, 10 Jun 2024 22:22:32 +0900 Subject: [PATCH 12/15] Upgrade gems --- Gemfile.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index dd684a517..7876f48a1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -5,7 +5,7 @@ GEM base64 nkf rexml - activesupport (7.1.3.2) + activesupport (7.1.3.4) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) @@ -23,24 +23,24 @@ GEM artifactory (3.0.17) atomos (0.1.3) aws-eventstream (1.3.0) - aws-partitions (1.917.0) - aws-sdk-core (3.192.1) + aws-partitions (1.941.0) + aws-sdk-core (3.197.0) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.8) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.79.0) - aws-sdk-core (~> 3, >= 3.191.0) + aws-sdk-kms (1.83.0) + aws-sdk-core (~> 3, >= 3.197.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.147.0) - aws-sdk-core (~> 3, >= 3.192.0) + aws-sdk-s3 (1.152.0) + aws-sdk-core (~> 3, >= 3.197.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.8) aws-sigv4 (1.8.0) aws-eventstream (~> 1, >= 1.0.2) babosa (1.0.4) base64 (0.2.0) - bigdecimal (3.1.7) + bigdecimal (3.1.8) claide (1.1.0) cocoapods (1.15.2) addressable (~> 2.8) @@ -83,7 +83,7 @@ GEM colored2 (3.1.2) commander (4.6.0) highline (~> 2.0.0) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.3) connection_pool (2.4.1) declarative (0.0.20) digest-crc (0.6.5) @@ -166,7 +166,7 @@ GEM xcodeproj (>= 1.13.0, < 2.0.0) xcpretty (~> 0.3.0) xcpretty-travis-formatter (>= 0.0.3, < 2.0.0) - ffi (1.16.3) + ffi (1.17.0) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) @@ -207,10 +207,10 @@ GEM os (>= 0.9, < 2.0) signet (>= 0.16, < 2.a) highline (2.0.3) - http-cookie (1.0.5) + http-cookie (1.0.6) domain_name (~> 0.5) httpclient (2.8.3) - i18n (1.14.4) + i18n (1.14.5) concurrent-ruby (~> 1.0) jmespath (1.6.2) json (2.7.2) @@ -218,10 +218,10 @@ GEM base64 mini_magick (4.12.0) mini_mime (1.1.5) - minitest (5.22.3) + minitest (5.23.1) molinillo (0.8.0) multi_json (1.15.0) - multipart-post (2.4.0) + multipart-post (2.4.1) mutex_m (0.2.0) nanaimo (0.3.0) nap (1.1.0) @@ -238,8 +238,8 @@ GEM trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) retriable (3.1.2) - rexml (3.2.8) - strscan (>= 3.0.9) + rexml (3.2.9) + strscan rouge (2.0.7) ruby-macho (2.5.1) ruby2_keywords (0.0.5) From 8ac677ff27dacc91f544e127f6525bbec7828e11 Mon Sep 17 00:00:00 2001 From: onevcat Date: Mon, 10 Jun 2024 22:23:31 +0900 Subject: [PATCH 13/15] Upgrade default to Xcode 15.4 --- fastlane/Fastfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 43da85dfc..ba62d50bc 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -85,7 +85,7 @@ platform :ios do lane :xcframework do |options| target_version = "Kingfisher-#{options[:version]}" - xcversion(version: "~> 15.2") + xcversion(version: "~> 15.4") FileUtils.rm_rf '../build' frameworks = {} @@ -131,7 +131,7 @@ platform :ios do end before_all do |lane| - xcode_version = ENV["XCODE_VERSION"] || "15.3" + xcode_version = ENV["XCODE_VERSION"] || "15.4" xcodes(version: xcode_version, select_for_current_build_only: true) end From 2ef543ee21d63734e1c004ad6c870255e8716c50 Mon Sep 17 00:00:00 2001 From: onevcat Date: Mon, 10 Jun 2024 22:29:12 +0900 Subject: [PATCH 14/15] Bump version to 7.12.0 --- CHANGELOG.md | 14 ++++++++++++++ Kingfisher.podspec | 2 +- Kingfisher.xcodeproj/project.pbxproj | 8 ++++---- Sources/Info.plist | 4 ++-- Tests/KingfisherTests/Info.plist | 4 ++-- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7436afb95..d2380ba0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,20 @@ ----- +## [7.12.0 - Lucky Seven](https://github.com/onevcat/Kingfisher/releases/tag/7.12.0) (2024-06-10) + +#### Add +* Mark the `removeSizeExceededValues` method in `DiskStorage` as `public`. Now it is possible to call this method to trigger a cleanup of the disk cache manually. [#2214](https://github.com/onevcat/Kingfisher/pull/2214) @nickruddeni +* A new `PHPickerResultImageDataProvider` for loading and caching images from `PHPickerResult`. [#2233](https://github.com/onevcat/Kingfisher/pull/2233) @nuomi1 +* An option of `reducePriorityOnDisappear` for SwiftUI. It sets a lower priority for the image download task when the view disappears, and restore it when re-appears. [#2211](https://github.com/onevcat/Kingfisher/pull/2211) @Aelx-Vaiman + +#### Fix +* Some improvements for documentation grammar and typos. [#2236](https://github.com/onevcat/Kingfisher/pull/2236) @FlyingCaiChong +* Use `.process` for the `PrivacyInfo.xcprivacy` in SPM to follow the practice suggested by Apple. [#2243](https://github.com/onevcat/Kingfisher/pull/2243) @BorysKhl @onevcat +* An issue that the file extension was not correctly retrieved for calculating hash file name when `autoExtAfterHashedFileName` is set to `true`. [#2250](https://github.com/onevcat/Kingfisher/pull/2250) @freezy7 + +--- + ## [7.11.0 - visionOS for CocoaPods](https://github.com/onevcat/Kingfisher/releases/tag/7.11.0) (2024-02-12) #### Add diff --git a/Kingfisher.podspec b/Kingfisher.podspec index 283d132e7..60ed3a335 100644 --- a/Kingfisher.podspec +++ b/Kingfisher.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Kingfisher" - s.version = "7.11.0" + s.version = "7.12.0" s.summary = "A lightweight and pure Swift implemented library for downloading and cacheing image from the web." s.description = <<-DESC diff --git a/Kingfisher.xcodeproj/project.pbxproj b/Kingfisher.xcodeproj/project.pbxproj index 04c40fd0c..e3db12658 100644 --- a/Kingfisher.xcodeproj/project.pbxproj +++ b/Kingfisher.xcodeproj/project.pbxproj @@ -1078,10 +1078,10 @@ CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES; - CURRENT_PROJECT_VERSION = 2700; + CURRENT_PROJECT_VERSION = 2739; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 2700; + DYLIB_CURRENT_VERSION = 2739; DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; @@ -1134,10 +1134,10 @@ CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; CLANG_WARN_UNREACHABLE_CODE = YES_AGGRESSIVE; CLANG_WARN__EXIT_TIME_DESTRUCTORS = YES; - CURRENT_PROJECT_VERSION = 2700; + CURRENT_PROJECT_VERSION = 2739; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 2700; + DYLIB_CURRENT_VERSION = 2739; DYLIB_INSTALL_NAME_BASE = "@rpath"; GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES; GCC_TREAT_INCOMPATIBLE_POINTER_TYPE_WARNINGS_AS_ERRORS = YES; diff --git a/Sources/Info.plist b/Sources/Info.plist index 1ba445b4a..cf8ac69f2 100644 --- a/Sources/Info.plist +++ b/Sources/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 7.11.0 + 7.12.0 CFBundleSignature ???? CFBundleVersion - 2700 + 2739 NSPrincipalClass diff --git a/Tests/KingfisherTests/Info.plist b/Tests/KingfisherTests/Info.plist index 12e08f96f..f5f7b8e5f 100644 --- a/Tests/KingfisherTests/Info.plist +++ b/Tests/KingfisherTests/Info.plist @@ -15,10 +15,10 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 7.11.0 + 7.12.0 CFBundleSignature ???? CFBundleVersion - 2700 + 2739 From 7e1d2c0d3c897c5485226f56bc8e196dd66136cc Mon Sep 17 00:00:00 2001 From: onevcat Date: Mon, 10 Jun 2024 22:53:03 +0900 Subject: [PATCH 15/15] Set CI job continue on error --- .github/workflows/build.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ab3a90711..1edb36b61 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -5,6 +5,7 @@ on: [push, pull_request] jobs: run-test: runs-on: self-hosted + continue-on-error: true strategy: matrix: destination: [