From cb527996d6f47024c48c4afb80a6db2869556263 Mon Sep 17 00:00:00 2001 From: Jan Gorman Date: Wed, 28 Sep 2022 09:01:44 +0200 Subject: [PATCH] Bump podspec, some cleanup --- .swiftlint.yml | 8 +- Agrume.podspec | 4 +- Agrume.xcodeproj/project.pbxproj | 34 +++-- Agrume/Agrume.swift | 117 ++++++++++++++---- Agrume/AgrumeCell.swift | 8 +- Agrume/AgrumePhotoLibraryHelper.swift | 2 +- Agrume/ImageDownloader.swift | 9 +- .../LiveTextViewController.swift | 9 +- Frameworks/SwiftyGif | 2 +- 9 files changed, 145 insertions(+), 48 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index c30d77a..35c1cd8 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,3 +1,7 @@ +excluded: + - Frameworks/SwiftyGif + - Carthage/Checkouts + identifier_name: min_length: error: 3 @@ -58,7 +62,3 @@ disabled_rules: - vertical_parameter_alignment - force_try - object_literal - -excluded: - - Frameworks/SwiftyGif - - Carthage/Checkouts \ No newline at end of file diff --git a/Agrume.podspec b/Agrume.podspec index c723349..624edfa 100644 --- a/Agrume.podspec +++ b/Agrume.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "Agrume" - s.version = "5.8.4" + s.version = "5.8.5" s.summary = "An iOS image viewer written in Swift." s.swift_version = "5.0" @@ -16,7 +16,7 @@ Pod::Spec.new do |s| s.author = { "Jan Gorman" => "gorman.jan@gmail.com" } s.social_media_url = "https://twitter.com/JanGorman" - s.platform = :ios, "9.0" + s.platform = :ios, "13.0" s.source = { :git => "https://github.com/JanGorman/Agrume.git", :tag => s.version} diff --git a/Agrume.xcodeproj/project.pbxproj b/Agrume.xcodeproj/project.pbxproj index ecdc646..63f6020 100644 --- a/Agrume.xcodeproj/project.pbxproj +++ b/Agrume.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -309,6 +309,7 @@ /* Begin PBXShellScriptBuildPhase section */ 77CAF6741FADFD45000C0929 /* Run SwiftLint */ = { isa = PBXShellScriptBuildPhase; + alwaysOutOfDate = 1; buildActionMask = 2147483647; files = ( ); @@ -412,7 +413,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -466,10 +467,11 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -489,7 +491,11 @@ ENABLE_TESTABILITY = YES; INFOPLIST_FILE = Agrume/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = "com.schnaub.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -510,7 +516,11 @@ ENABLE_TESTABILITY = YES; INFOPLIST_FILE = Agrume/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = "com.schnaub.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; @@ -527,7 +537,11 @@ "$(inherited)", ); INFOPLIST_FILE = AgrumeTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = "com.schnaub.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -541,7 +555,11 @@ buildSettings = { CLANG_ENABLE_MODULES = YES; INFOPLIST_FILE = AgrumeTests/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + "@loader_path/Frameworks", + ); PRODUCT_BUNDLE_IDENTIFIER = "com.schnaub.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; diff --git a/Agrume/Agrume.swift b/Agrume/Agrume.swift index ee538a3..b832728 100644 --- a/Agrume/Agrume.swift +++ b/Agrume/Agrume.swift @@ -65,9 +65,20 @@ public final class Agrume: UIViewController { /// - dismissal: The dismiss configuration /// - overlayView: View to overlay the image (does not display with 'button' dismissals) /// - enableLiveText: Enables Live Text interaction, iOS 16 only - public convenience init(image: UIImage, background: Background = .colored(.black), - dismissal: Dismissal = .withPan(.standard), overlayView: AgrumeOverlayView? = nil, enableLiveText: Bool = false) { - self.init(images: [image], background: background, dismissal: dismissal, overlayView: overlayView, enableLiveText: enableLiveText) + public convenience init( + image: UIImage, + background: Background = .colored(.black), + dismissal: Dismissal = .withPan(.standard), + overlayView: AgrumeOverlayView? = nil, + enableLiveText: Bool = false + ) { + self.init( + images: [image], + background: background, + dismissal: dismissal, + overlayView: overlayView, + enableLiveText: enableLiveText + ) } /// Initialize with a single image url @@ -78,9 +89,20 @@ public final class Agrume: UIViewController { /// - dismissal: The dismiss configuration /// - overlayView: View to overlay the image (does not display with 'button' dismissals) /// - enableLiveText: Enables Live Text interaction, iOS 16 only - public convenience init(url: URL, background: Background = .colored(.black), dismissal: Dismissal = .withPan(.standard), - overlayView: AgrumeOverlayView? = nil, enableLiveText: Bool = false) { - self.init(urls: [url], background: background, dismissal: dismissal, overlayView: overlayView, enableLiveText: enableLiveText) + public convenience init( + url: URL, + background: Background = .colored(.black), + dismissal: Dismissal = .withPan(.standard), + overlayView: AgrumeOverlayView? = nil, + enableLiveText: Bool = false + ) { + self.init( + urls: [url], + background: background, + dismissal: dismissal, + overlayView: overlayView, + enableLiveText: enableLiveText + ) } /// Initialize with a data source @@ -92,10 +114,23 @@ public final class Agrume: UIViewController { /// - dismissal: The dismiss configuration /// - overlayView: View to overlay the image (does not display with 'button' dismissals) /// - enableLiveText: Enables Live Text interaction, iOS 16 only - public convenience init(dataSource: AgrumeDataSource, startIndex: Int = 0, background: Background = .colored(.black), - dismissal: Dismissal = .withPan(.standard), overlayView: AgrumeOverlayView? = nil, enableLiveText: Bool = false) { - self.init(images: nil, dataSource: dataSource, startIndex: startIndex, background: background, dismissal: dismissal, - overlayView: overlayView, enableLiveText: enableLiveText) + public convenience init( + dataSource: AgrumeDataSource, + startIndex: Int = 0, + background: Background = .colored(.black), + dismissal: Dismissal = .withPan(.standard), + overlayView: AgrumeOverlayView? = nil, + enableLiveText: Bool = false + ) { + self.init( + images: nil, + dataSource: dataSource, + startIndex: startIndex, + background: background, + dismissal: dismissal, + overlayView: overlayView, + enableLiveText: enableLiveText + ) } /// Initialize with an array of images @@ -107,9 +142,23 @@ public final class Agrume: UIViewController { /// - dismissal: The dismiss configuration /// - overlayView: View to overlay the image (does not display with 'button' dismissals) /// - enableLiveText: Enables Live Text interaction, iOS 16 only - public convenience init(images: [UIImage], startIndex: Int = 0, background: Background = .colored(.black), - dismissal: Dismissal = .withPan(.standard), overlayView: AgrumeOverlayView? = nil, enableLiveText: Bool = false) { - self.init(images: images, urls: nil, startIndex: startIndex, background: background, dismissal: dismissal, overlayView: overlayView, enableLiveText: enableLiveText) + public convenience init( + images: [UIImage], + startIndex: Int = 0, + background: Background = .colored(.black), + dismissal: Dismissal = .withPan(.standard), + overlayView: AgrumeOverlayView? = nil, + enableLiveText: Bool = false + ) { + self.init( + images: images, + urls: nil, + startIndex: startIndex, + background: background, + dismissal: dismissal, + overlayView: overlayView, + enableLiveText: enableLiveText + ) } /// Initialize with an array of image urls @@ -121,13 +170,35 @@ public final class Agrume: UIViewController { /// - dismissal: The dismiss configuration /// - overlayView: View to overlay the image (does not display with 'button' dismissals) /// - enableLiveText: Enables Live Text interaction, iOS 16 only - public convenience init(urls: [URL], startIndex: Int = 0, background: Background = .colored(.black), - dismissal: Dismissal = .withPan(.standard), overlayView: AgrumeOverlayView? = nil, enableLiveText: Bool = false) { - self.init(images: nil, urls: urls, startIndex: startIndex, background: background, dismissal: dismissal, overlayView: overlayView, enableLiveText: enableLiveText) + public convenience init( + urls: [URL], + startIndex: Int = 0, + background: Background = .colored(.black), + dismissal: Dismissal = .withPan(.standard), + overlayView: AgrumeOverlayView? = nil, + enableLiveText: Bool = false + ) { + self.init( + images: nil, + urls: urls, + startIndex: startIndex, + background: background, + dismissal: dismissal, + overlayView: overlayView, + enableLiveText: enableLiveText + ) } - private init(images: [UIImage]? = nil, urls: [URL]? = nil, dataSource: AgrumeDataSource? = nil, startIndex: Int, - background: Background, dismissal: Dismissal, overlayView: AgrumeOverlayView? = nil, enableLiveText: Bool = false) { + private init( + images: [UIImage]? = nil, + urls: [URL]? = nil, + dataSource: AgrumeDataSource? = nil, + startIndex: Int, + background: Background, + dismissal: Dismissal, + overlayView: AgrumeOverlayView? = nil, + enableLiveText: Bool = false + ) { switch (images, urls) { case (let images?, nil): self.images = images.map { AgrumeImage(image: $0) } @@ -216,9 +287,9 @@ public final class Agrume: UIViewController { let indicatorStyle: UIActivityIndicatorView.Style switch background { case let .blurred(style): - indicatorStyle = style == .dark ? .whiteLarge : .gray + indicatorStyle = style == .dark ? .large : .medium case let .colored(color): - indicatorStyle = color.isLight ? .gray : .whiteLarge + indicatorStyle = color.isLight ? .medium : .large } let spinner = UIActivityIndicatorView(style: indicatorStyle) spinner.center = view.center @@ -255,7 +326,7 @@ public final class Agrume: UIViewController { let replacement = with(images[index]) { $0.url = nil $0.image = image - if let newTitle = newTitle { + if let newTitle { $0.title = newTitle } } @@ -275,7 +346,7 @@ public final class Agrume: UIViewController { let replacement = with(images[index]) { $0.image = nil $0.url = url - if let newTitle = newTitle { + if let newTitle { $0.title = newTitle } } @@ -309,7 +380,7 @@ public final class Agrume: UIViewController { return } fetchImage(forIndex: currentIndex) { [weak self] image in - guard let self = self else { + guard let self else { return } self.onLongPress?(image, self) diff --git a/Agrume/AgrumeCell.swift b/Agrume/AgrumeCell.swift index 2028ff7..fcd12d4 100644 --- a/Agrume/AgrumeCell.swift +++ b/Agrume/AgrumeCell.swift @@ -183,8 +183,8 @@ extension AgrumeCell: UIGestureRecognizerDelegate { CATransaction.begin() CATransaction.setCompletionBlock { [weak self] in - // captures self weakly to avoid extending the lifetime of the cell - guard let self = self else { return } + // captures self weakly to avoid extending the lifetime of the cell + guard let self else { return } self.contentView.isUserInteractionEnabled = true } scrollView.zoom(to: destination, animated: true) @@ -257,7 +257,7 @@ extension AgrumeCell: UIGestureRecognizerDelegate { @objc private func dismissPan(_ gesture: UIPanGestureRecognizer) { - guard let panPhysics = panPhysics else { return } + guard let panPhysics else { return } let translation = gesture.translation(in: gesture.view) let locationInView = gesture.location(in: gesture.view) @@ -311,7 +311,7 @@ extension AgrumeCell: UIGestureRecognizerDelegate { } private func dismissWithFlick(_ velocity: CGPoint) { - guard let panPhysics = panPhysics else { return } + guard let panPhysics else { return } flickedToDismiss = true diff --git a/Agrume/AgrumePhotoLibraryHelper.swift b/Agrume/AgrumePhotoLibraryHelper.swift index 0f483c7..9b54cea 100644 --- a/Agrume/AgrumePhotoLibraryHelper.swift +++ b/Agrume/AgrumePhotoLibraryHelper.swift @@ -25,7 +25,7 @@ public final class AgrumePhotoLibraryHelper: NSObject { /// Save the current photo shown in the user's photo library using Long Press Gesture /// Make sure to have NSPhotoLibraryUsageDescription (ios 10) and NSPhotoLibraryAddUsageDescription (ios 11+) in your info.plist public func makeSaveToLibraryLongPressGesture(for image: UIImage?, viewController: UIViewController) { - guard let image = image else { + guard let image else { return } let view = viewController.view! diff --git a/Agrume/ImageDownloader.swift b/Agrume/ImageDownloader.swift index ef65f87..1b469cf 100644 --- a/Agrume/ImageDownloader.swift +++ b/Agrume/ImageDownloader.swift @@ -18,7 +18,7 @@ final class ImageDownloader { completion(image) } } - guard let data = data, error == nil else { + guard let data, error == nil else { return } if isAnimatedImage(data) { @@ -41,9 +41,10 @@ final class ImageDownloader { private static func isAnimatedImage(_ data: Data) -> Bool { guard let imageSource = CGImageSourceCreateWithData(data as CFData, nil), - let imageType = CGImageSourceGetType(imageSource) else { - return false - } + let imageType = CGImageSourceGetType(imageSource) + else { + return false + } return UTTypeConformsTo(imageType, kUTTypeGIF) } diff --git a/Example/Agrume Example/LiveTextViewController.swift b/Example/Agrume Example/LiveTextViewController.swift index 471684f..8b11bda 100644 --- a/Example/Agrume Example/LiveTextViewController.swift +++ b/Example/Agrume Example/LiveTextViewController.swift @@ -17,7 +17,14 @@ final class LiveTextViewController: UIViewController { return } - let alert = UIAlertController(title: "Not supported on this device", message: "Live Text is available for devices with iOS 16 (or above) and A12 (or above) Bionic chip (iPhone XS and later, physical device only)", preferredStyle: .alert) + let alert = UIAlertController( + title: "Not supported on this device", + message: """ + Live Text is available for devices with iOS 16 (or above) and A12 (or above) + Bionic chip (iPhone XS and later, physical device only) + """, + preferredStyle: .alert + ) alert.addAction(UIAlertAction(title: "OK", style: .cancel)) present(alert, animated: true) } diff --git a/Frameworks/SwiftyGif b/Frameworks/SwiftyGif index db0c122..8e3047b 160000 --- a/Frameworks/SwiftyGif +++ b/Frameworks/SwiftyGif @@ -1 +1 @@ -Subproject commit db0c122b671bc9760385e0355be00eede3b7bb44 +Subproject commit 8e3047b7284e2fcff1117b01e0351ac0a4efc9ea