diff --git a/Demo/Demo.xcodeproj/project.pbxproj b/Demo/Demo.xcodeproj/project.pbxproj index fcb15f84..df34ba49 100644 --- a/Demo/Demo.xcodeproj/project.pbxproj +++ b/Demo/Demo.xcodeproj/project.pbxproj @@ -270,6 +270,7 @@ SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + TVOS_DEPLOYMENT_TARGET = 13.0; }; name = Debug; }; @@ -323,6 +324,7 @@ SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_OPTIMIZATION_LEVEL = "-O"; + TVOS_DEPLOYMENT_TARGET = 13.0; VALIDATE_PRODUCT = YES; }; name = Release; @@ -361,7 +363,6 @@ SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2,3"; - TVOS_DEPLOYMENT_TARGET = 13.0; }; name = Debug; }; @@ -398,7 +399,6 @@ SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2,3"; - TVOS_DEPLOYMENT_TARGET = 13.0; }; name = Release; }; diff --git a/Sources/NavigationTransitions/NavigationTransition+UIKit.swift b/Sources/NavigationTransitions/NavigationTransition+UIKit.swift index 6afcc1a6..51469087 100644 --- a/Sources/NavigationTransitions/NavigationTransition+UIKit.swift +++ b/Sources/NavigationTransitions/NavigationTransition+UIKit.swift @@ -135,12 +135,7 @@ extension UINavigationController: RuntimeAssociation { _ transition: AnyNavigationTransition, interactivity: AnyNavigationTransition.Interactivity = .default ) { - // fix for https://stackoverflow.com/q/73753796/1922543 - swizzle( - UINavigationController.self, - #selector(UINavigationController.popToViewController), - #selector(UINavigationController.popToViewController_forceAnimated) - ) + backDeploy96852321() if defaultDelegate == nil { defaultDelegate = delegate @@ -193,6 +188,28 @@ extension UINavigationController: RuntimeAssociation { #endif } + private func backDeploy96852321() { + func forceAnimatedPopToViewController() { + swizzle( + UINavigationController.self, + #selector(UINavigationController.popToViewController), + #selector(UINavigationController.popToViewController_forceAnimated) + ) + } + + if #available(iOS 16.2, macCatalyst 16.2, tvOS 16.2, *) {} else { + #if targetEnvironment(macCatalyst) + let major = ProcessInfo.processInfo.operatingSystemVersion.majorVersion + let minor = ProcessInfo.processInfo.operatingSystemVersion.minorVersion + if (major, minor) < (13, 1) { + forceAnimatedPopToViewController() + } + #else + forceAnimatedPopToViewController() + #endif + } + } + @available(tvOS, unavailable) private func exclusivelyEnableGestureRecognizer(_ gestureRecognizer: UIPanGestureRecognizer?) { for recognizer in [defaultEdgePanRecognizer!, defaultPanRecognizer!, edgePanRecognizer!, panRecognizer!] { @@ -206,8 +223,7 @@ extension UINavigationController: RuntimeAssociation { } extension UINavigationController { - @objc func popToViewController_forceAnimated(_ viewController: UIViewController, animated: Bool) -> [UIViewController]? { - // TODO: `if #unavailable(iOS 17?...)` when fixed by Apple + @objc fileprivate func popToViewController_forceAnimated(_ viewController: UIViewController, animated: Bool) -> [UIViewController]? { popToViewController_forceAnimated(viewController, animated: true) } }