From 0960699699ec6eb9e9b5b671ee8b8c73152eea26 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 28 Jun 2022 17:28:48 -0700 Subject: [PATCH] Fix building for iOS 14 --- Tusker.xcodeproj/project.pbxproj | 6 +-- .../Compose/ComposeAttachmentRow.swift | 1 + .../Large Image/LargeImageContentView.swift | 7 +++- .../EnhancedNavigationViewController.swift | 38 ++++++++++++++----- 4 files changed, 36 insertions(+), 16 deletions(-) diff --git a/Tusker.xcodeproj/project.pbxproj b/Tusker.xcodeproj/project.pbxproj index 3e999cec..209b9a30 100644 --- a/Tusker.xcodeproj/project.pbxproj +++ b/Tusker.xcodeproj/project.pbxproj @@ -2205,8 +2205,7 @@ CURRENT_PROJECT_VERSION = 31; DEVELOPMENT_TEAM = V4WK9KR9U2; INFOPLIST_FILE = Tusker/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.3; + IPHONEOS_DEPLOYMENT_TARGET = 14.3; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -2236,8 +2235,7 @@ CURRENT_PROJECT_VERSION = 31; DEVELOPMENT_TEAM = V4WK9KR9U2; INFOPLIST_FILE = Tusker/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - "IPHONEOS_DEPLOYMENT_TARGET[sdk=macosx*]" = 14.3; + IPHONEOS_DEPLOYMENT_TARGET = 14.3; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Tusker/Screens/Compose/ComposeAttachmentRow.swift b/Tusker/Screens/Compose/ComposeAttachmentRow.swift index 0afbbe7f..a4aa7040 100644 --- a/Tusker/Screens/Compose/ComposeAttachmentRow.swift +++ b/Tusker/Screens/Compose/ComposeAttachmentRow.swift @@ -154,6 +154,7 @@ extension ComposeAttachmentRow { } private extension View { + @available(iOS, obsoleted: 16.0) @ViewBuilder func contextMenu(@ViewBuilder menuItems: () -> M, @ViewBuilder previewIfAvailable preview: () -> P) -> some View { if #available(iOS 16.0, *) { diff --git a/Tusker/Screens/Large Image/LargeImageContentView.swift b/Tusker/Screens/Large Image/LargeImageContentView.swift index d9ca2897..9608c42c 100644 --- a/Tusker/Screens/Large Image/LargeImageContentView.swift +++ b/Tusker/Screens/Large Image/LargeImageContentView.swift @@ -17,7 +17,7 @@ protocol LargeImageContentView: UIView { func grayscaleStateChanged() } -class LargeImageImageContentView: UIImageView, LargeImageContentView, ImageAnalysisInteractionDelegate { +class LargeImageImageContentView: UIImageView, LargeImageContentView { @available(iOS 16.0, *) private static let analyzer = ImageAnalyzer() @@ -76,7 +76,10 @@ class LargeImageImageContentView: UIImageView, LargeImageContentView, ImageAnaly self.image = image } } - +} + +@available(iOS 16.0, *) +extension LargeImageImageContentView: ImageAnalysisInteractionDelegate { func presentingViewController(for interaction: ImageAnalysisInteraction) -> UIViewController? { return owner } diff --git a/Tusker/Screens/Utilities/EnhancedNavigationViewController.swift b/Tusker/Screens/Utilities/EnhancedNavigationViewController.swift index b20de711..f92b5cf4 100644 --- a/Tusker/Screens/Utilities/EnhancedNavigationViewController.swift +++ b/Tusker/Screens/Utilities/EnhancedNavigationViewController.swift @@ -20,10 +20,13 @@ class EnhancedNavigationViewController: UINavigationController { override var viewControllers: [UIViewController] { didSet { poppedViewControllers = [] - for vc in viewControllers { - configureNavItem(vc.navigationItem) + if #available(iOS 16.0, *) { + // TODO: this for loop might not be necessary + for vc in viewControllers { + configureNavItem(vc.navigationItem) + } + updateTopNavItemState() } - updateTopNavItemState() } } @@ -32,7 +35,8 @@ class EnhancedNavigationViewController: UINavigationController { self.interactivePushTransition = InteractivePushTransition(navigationController: self) - if let topViewController { + if #available(iOS 16.0, *), + let topViewController { configureNavItem(topViewController.navigationItem) updateTopNavItemState() } @@ -42,7 +46,9 @@ class EnhancedNavigationViewController: UINavigationController { let popped = performAfterAnimating(block: { super.popViewController(animated: animated) }, after: { - self.updateTopNavItemState() + if #available(iOS 16.0, *) { + self.updateTopNavItemState() + } }, animated: animated) if let popped { poppedViewControllers.insert(popped, at: 0) @@ -54,7 +60,9 @@ class EnhancedNavigationViewController: UINavigationController { let popped = performAfterAnimating(block: { super.popToRootViewController(animated: animated) }, after: { - self.updateTopNavItemState() + if #available(iOS 16.0, *) { + self.updateTopNavItemState() + } }, animated: animated) if let popped { poppedViewControllers = popped @@ -66,7 +74,9 @@ class EnhancedNavigationViewController: UINavigationController { let popped = performAfterAnimating(block: { super.popToViewController(viewController, animated: animated) }, after: { - self.updateTopNavItemState() + if #available(iOS 16.0, *) { + self.updateTopNavItemState() + } }, animated: animated) if let popped { poppedViewControllers.insert(contentsOf: popped, at: 0) @@ -81,11 +91,15 @@ class EnhancedNavigationViewController: UINavigationController { self.poppedViewControllers = [] } - configureNavItem(viewController.navigationItem) + if #available(iOS 16.0, *) { + configureNavItem(viewController.navigationItem) + } super.pushViewController(viewController, animated: animated) - updateTopNavItemState() + if #available(iOS 16.0, *) { + updateTopNavItemState() + } } func pushPoppedViewController() { @@ -115,7 +129,9 @@ class EnhancedNavigationViewController: UINavigationController { pushViewController(target, animated: true) }, after: { self.viewControllers.insert(contentsOf: toInsert, at: self.viewControllers.count - 1) - self.updateTopNavItemState() + if #available(iOS 16.0, *) { + self.updateTopNavItemState() + } }, animated: true) } @@ -135,6 +151,7 @@ class EnhancedNavigationViewController: UINavigationController { }) } + @available(iOS 16.0, *) private func configureNavItem(_ navItem: UINavigationItem) { guard useBrowserStyleNavigation, UIDevice.current.userInterfaceIdiom != .phone else { @@ -183,6 +200,7 @@ class EnhancedNavigationViewController: UINavigationController { ] } + @available(iOS 16.0, *) private func updateTopNavItemState() { guard useBrowserStyleNavigation, UIDevice.current.userInterfaceIdiom != .phone,