diff --git a/Example/Example/Main/MainViewController.swift b/Example/Example/Main/MainViewController.swift index 2bf42e950..8d4f087ae 100644 --- a/Example/Example/Main/MainViewController.swift +++ b/Example/Example/Main/MainViewController.swift @@ -35,11 +35,9 @@ final class MainViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() -#if compiler(>=5.7) if #available(iOS 16, *) { contentView.textView.isFindInteractionEnabled = true } -#endif contentView.textView.inputAccessoryView = toolsView setupMenuButton() setupTextView() @@ -48,7 +46,6 @@ final class MainViewController: UIViewController { } private extension MainViewController { -#if compiler(>=5.7) @available(iOS 16, *) @objc private func presentFind() { contentView.textView.findInteraction?.presentFindNavigator(showingReplace: false) @@ -58,7 +55,6 @@ private extension MainViewController { @objc private func presentFindAndReplace() { contentView.textView.findInteraction?.presentFindNavigator(showingReplace: true) } -#endif private func setupTextView() { var text = "" @@ -89,7 +85,6 @@ private extension MainViewController { private func makeFeaturesMenuElements() -> [UIMenuElement] { var menuElements: [UIMenuElement] = [] -#if compiler(>=5.7) if #available(iOS 16, *) { menuElements += [ UIMenu(options: .displayInline, children: [ @@ -102,7 +97,6 @@ private extension MainViewController { ]) ] } -#endif menuElements += [ UIAction(title: "Go to Line") { [weak self] _ in self?.presentGoToLineAlert() diff --git a/Sources/Runestone/TextView/Appearance/DefaultTheme.swift b/Sources/Runestone/TextView/Appearance/DefaultTheme.swift index 53523ab5d..b392ec33f 100644 --- a/Sources/Runestone/TextView/Appearance/DefaultTheme.swift +++ b/Sources/Runestone/TextView/Appearance/DefaultTheme.swift @@ -67,7 +67,6 @@ public final class DefaultTheme: Runestone.Theme { } } -#if compiler(>=5.7) @available(iOS 16.0, *) public func highlightedRange(forFoundTextRange foundTextRange: NSRange, ofStyle style: UITextSearchFoundTextStyle) -> HighlightedRange? { switch style { @@ -83,7 +82,6 @@ public final class DefaultTheme: Runestone.Theme { return nil } } -#endif } private extension UIColor { diff --git a/Sources/Runestone/TextView/Appearance/Theme.swift b/Sources/Runestone/TextView/Appearance/Theme.swift index 6482a2938..47c2a774e 100644 --- a/Sources/Runestone/TextView/Appearance/Theme.swift +++ b/Sources/Runestone/TextView/Appearance/Theme.swift @@ -51,7 +51,6 @@ public protocol Theme: AnyObject { /// /// See for more information on higlight names. func shadow(for highlightName: String) -> NSShadow? -#if compiler(>=5.7) /// Highlighted range for a text range matching a search query. /// /// This function is called when highlighting a search result that was found using the standard find/replace interaction enabled using . @@ -63,7 +62,6 @@ public protocol Theme: AnyObject { /// - Returns: The object used for highlighting the provided text range, or `nil` if the range should not be highlighted. @available(iOS 16, *) func highlightedRange(forFoundTextRange foundTextRange: NSRange, ofStyle style: UITextSearchFoundTextStyle) -> HighlightedRange? -#endif } public extension Theme { @@ -91,7 +89,6 @@ public extension Theme { nil } -#if compiler(>=5.7) @available(iOS 16, *) func highlightedRange(forFoundTextRange foundTextRange: NSRange, ofStyle style: UITextSearchFoundTextStyle) -> HighlightedRange? { switch style { @@ -105,5 +102,4 @@ public extension Theme { return nil } } -#endif } diff --git a/Sources/Runestone/TextView/Core/EditMenuController.swift b/Sources/Runestone/TextView/Core/EditMenuController.swift index ede4ffe98..1f7153b87 100644 --- a/Sources/Runestone/TextView/Core/EditMenuController.swift +++ b/Sources/Runestone/TextView/Core/EditMenuController.swift @@ -11,24 +11,18 @@ protocol EditMenuControllerDelegate: AnyObject { final class EditMenuController: NSObject { weak var delegate: EditMenuControllerDelegate? -#if compiler(>=5.7) @available(iOS 16, *) private var editMenuInteraction: UIEditMenuInteraction? { _editMenuInteraction as? UIEditMenuInteraction } private var _editMenuInteraction: Any? -#endif func setupEditMenu(in view: UIView) { -#if compiler(>=5.7) if #available(iOS 16, *) { setupEditMenuInteraction(in: view) } else { setupMenuController() } -#else - setupMenuController() -#endif } func presentEditMenu(from view: UIView, forTextIn range: NSRange) { @@ -36,7 +30,6 @@ final class EditMenuController: NSObject { let endCaretRect = caretRect(at: range.location + range.length) let menuWidth = min(endCaretRect.maxX - startCaretRect.minX, view.frame.width) let menuRect = CGRect(x: startCaretRect.minX, y: startCaretRect.minY, width: menuWidth, height: startCaretRect.height) -#if compiler(>=5.7) if #available(iOS 16, *) { let point = CGPoint(x: menuRect.midX, y: menuRect.minY) let configuration = UIEditMenuConfiguration(identifier: nil, sourcePoint: point) @@ -45,9 +38,6 @@ final class EditMenuController: NSObject { } else { UIMenuController.shared.showMenu(from: view, rect: menuRect) } -#else - UIMenuController.shared.showMenu(from: view, rect: menuRect) -#endif } func editMenu(for textRange: UITextRange, suggestedActions: [UIMenuElement]) -> UIMenu? { @@ -59,14 +49,12 @@ final class EditMenuController: NSObject { } private extension EditMenuController { -#if compiler(>=5.7) @available(iOS 16, *) private func setupEditMenuInteraction(in view: UIView) { let editMenuInteraction = UIEditMenuInteraction(delegate: self) _editMenuInteraction = editMenuInteraction view.addInteraction(editMenuInteraction) } -#endif private func setupMenuController() { // This is not necessary starting from iOS 16. @@ -100,7 +88,6 @@ private extension EditMenuController { } } -#if compiler(>=5.7) @available(iOS 16, *) extension EditMenuController: UIEditMenuInteractionDelegate { func editMenuInteraction(_ interaction: UIEditMenuInteraction, @@ -113,4 +100,3 @@ extension EditMenuController: UIEditMenuInteractionDelegate { } } } -#endif diff --git a/Sources/Runestone/TextView/Core/TextView.swift b/Sources/Runestone/TextView/Core/TextView.swift index b4aafbb06..d74265a2d 100644 --- a/Sources/Runestone/TextView/Core/TextView.swift +++ b/Sources/Runestone/TextView/Core/TextView.swift @@ -564,7 +564,6 @@ open class TextView: UIScrollView { } /// When enabled the text view will present a menu with actions actions such as Copy and Replace after navigating to a highlighted range. public var showMenuAfterNavigatingToHighlightedRange = true -#if compiler(>=5.7) /// A boolean value that enables a text view’s built-in find interaction. /// /// After enabling the find interaction, use [`presentFindNavigator(showingReplace:)`](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator) on to present the find navigator. @@ -586,18 +585,15 @@ open class TextView: UIScrollView { public var findInteraction: UIFindInteraction? { textSearchingHelper.findInteraction } -#endif private let textInputView: TextInputView private let editableTextInteraction = UITextInteraction(for: .editable) private let nonEditableTextInteraction = UITextInteraction(for: .nonEditable) -#if compiler(>=5.7) @available(iOS 16.0, *) private var editMenuInteraction: UIEditMenuInteraction? { _editMenuInteraction as? UIEditMenuInteraction } private var _editMenuInteraction: Any? -#endif private let tapGestureRecognizer = QuickTapGestureRecognizer() private var _inputAccessoryView: UIView? private let _inputAssistantItem = UITextInputAssistantItem() diff --git a/Sources/Runestone/TextView/SearchAndReplace/UITextSearchingHelper.swift b/Sources/Runestone/TextView/SearchAndReplace/UITextSearchingHelper.swift index 3fa1cfad2..ff2e28a09 100644 --- a/Sources/Runestone/TextView/SearchAndReplace/UITextSearchingHelper.swift +++ b/Sources/Runestone/TextView/SearchAndReplace/UITextSearchingHelper.swift @@ -2,7 +2,6 @@ import UIKit final class UITextSearchingHelper: NSObject { weak var textView: TextView? -#if compiler(>=5.7) var isFindInteractionEnabled = false { didSet { if isFindInteractionEnabled != oldValue { @@ -17,7 +16,6 @@ final class UITextSearchingHelper: NSObject { @available(iOS 16, *) var findInteraction: UIFindInteraction? { get { - // swiftlint:disable implicit_return guard let _findInteraction = _findInteraction else { return nil } @@ -25,14 +23,12 @@ final class UITextSearchingHelper: NSObject { fatalError("Expected _findInteraction to be of type \(UIFindInteraction.self)") } return findInteraction - // swiftlint:enable implicit_return } set { _findInteraction = newValue } } private var _findInteraction: Any? -#endif private let queue = OperationQueue() private var _textView: TextView { @@ -54,7 +50,6 @@ final class UITextSearchingHelper: NSObject { } } -#if compiler(>=5.7) @available(iOS 16, *) extension UITextSearchingHelper: UITextSearching { var supportsTextReplacement: Bool { @@ -201,4 +196,3 @@ private extension SearchQuery.MatchMethod { } } } -#endif