Skip to content

Commit 0ebbd66

Browse files
authored
Removes compiler version checks (#318)
* Removes compiler version checks * Fixes SwiftLint errors
1 parent a3d526b commit 0ebbd66

6 files changed

Lines changed: 0 additions & 36 deletions

File tree

Example/Example/Main/MainViewController.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,9 @@ final class MainViewController: UIViewController {
3535

3636
override func viewDidLoad() {
3737
super.viewDidLoad()
38-
#if compiler(>=5.7)
3938
if #available(iOS 16, *) {
4039
contentView.textView.isFindInteractionEnabled = true
4140
}
42-
#endif
4341
contentView.textView.inputAccessoryView = toolsView
4442
setupMenuButton()
4543
setupTextView()
@@ -48,7 +46,6 @@ final class MainViewController: UIViewController {
4846
}
4947

5048
private extension MainViewController {
51-
#if compiler(>=5.7)
5249
@available(iOS 16, *)
5350
@objc private func presentFind() {
5451
contentView.textView.findInteraction?.presentFindNavigator(showingReplace: false)
@@ -58,7 +55,6 @@ private extension MainViewController {
5855
@objc private func presentFindAndReplace() {
5956
contentView.textView.findInteraction?.presentFindNavigator(showingReplace: true)
6057
}
61-
#endif
6258

6359
private func setupTextView() {
6460
var text = ""
@@ -89,7 +85,6 @@ private extension MainViewController {
8985

9086
private func makeFeaturesMenuElements() -> [UIMenuElement] {
9187
var menuElements: [UIMenuElement] = []
92-
#if compiler(>=5.7)
9388
if #available(iOS 16, *) {
9489
menuElements += [
9590
UIMenu(options: .displayInline, children: [
@@ -102,7 +97,6 @@ private extension MainViewController {
10297
])
10398
]
10499
}
105-
#endif
106100
menuElements += [
107101
UIAction(title: "Go to Line") { [weak self] _ in
108102
self?.presentGoToLineAlert()

Sources/Runestone/TextView/Appearance/DefaultTheme.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ public final class DefaultTheme: Runestone.Theme {
6767
}
6868
}
6969

70-
#if compiler(>=5.7)
7170
@available(iOS 16.0, *)
7271
public func highlightedRange(forFoundTextRange foundTextRange: NSRange, ofStyle style: UITextSearchFoundTextStyle) -> HighlightedRange? {
7372
switch style {
@@ -83,7 +82,6 @@ public final class DefaultTheme: Runestone.Theme {
8382
return nil
8483
}
8584
}
86-
#endif
8785
}
8886

8987
private extension UIColor {

Sources/Runestone/TextView/Appearance/Theme.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ public protocol Theme: AnyObject {
5151
///
5252
/// See <doc:CreatingATheme> for more information on higlight names.
5353
func shadow(for highlightName: String) -> NSShadow?
54-
#if compiler(>=5.7)
5554
/// Highlighted range for a text range matching a search query.
5655
///
5756
/// This function is called when highlighting a search result that was found using the standard find/replace interaction enabled using <doc:TextView/isFindInteractionEnabled>.
@@ -63,7 +62,6 @@ public protocol Theme: AnyObject {
6362
/// - Returns: The object used for highlighting the provided text range, or `nil` if the range should not be highlighted.
6463
@available(iOS 16, *)
6564
func highlightedRange(forFoundTextRange foundTextRange: NSRange, ofStyle style: UITextSearchFoundTextStyle) -> HighlightedRange?
66-
#endif
6765
}
6866

6967
public extension Theme {
@@ -91,7 +89,6 @@ public extension Theme {
9189
nil
9290
}
9391

94-
#if compiler(>=5.7)
9592
@available(iOS 16, *)
9693
func highlightedRange(forFoundTextRange foundTextRange: NSRange, ofStyle style: UITextSearchFoundTextStyle) -> HighlightedRange? {
9794
switch style {
@@ -105,5 +102,4 @@ public extension Theme {
105102
return nil
106103
}
107104
}
108-
#endif
109105
}

Sources/Runestone/TextView/Core/EditMenuController.swift

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,25 @@ protocol EditMenuControllerDelegate: AnyObject {
1111
final class EditMenuController: NSObject {
1212
weak var delegate: EditMenuControllerDelegate?
1313

14-
#if compiler(>=5.7)
1514
@available(iOS 16, *)
1615
private var editMenuInteraction: UIEditMenuInteraction? {
1716
_editMenuInteraction as? UIEditMenuInteraction
1817
}
1918
private var _editMenuInteraction: Any?
20-
#endif
2119

2220
func setupEditMenu(in view: UIView) {
23-
#if compiler(>=5.7)
2421
if #available(iOS 16, *) {
2522
setupEditMenuInteraction(in: view)
2623
} else {
2724
setupMenuController()
2825
}
29-
#else
30-
setupMenuController()
31-
#endif
3226
}
3327

3428
func presentEditMenu(from view: UIView, forTextIn range: NSRange) {
3529
let startCaretRect = caretRect(at: range.location)
3630
let endCaretRect = caretRect(at: range.location + range.length)
3731
let menuWidth = min(endCaretRect.maxX - startCaretRect.minX, view.frame.width)
3832
let menuRect = CGRect(x: startCaretRect.minX, y: startCaretRect.minY, width: menuWidth, height: startCaretRect.height)
39-
#if compiler(>=5.7)
4033
if #available(iOS 16, *) {
4134
let point = CGPoint(x: menuRect.midX, y: menuRect.minY)
4235
let configuration = UIEditMenuConfiguration(identifier: nil, sourcePoint: point)
@@ -45,9 +38,6 @@ final class EditMenuController: NSObject {
4538
} else {
4639
UIMenuController.shared.showMenu(from: view, rect: menuRect)
4740
}
48-
#else
49-
UIMenuController.shared.showMenu(from: view, rect: menuRect)
50-
#endif
5141
}
5242

5343
func editMenu(for textRange: UITextRange, suggestedActions: [UIMenuElement]) -> UIMenu? {
@@ -59,14 +49,12 @@ final class EditMenuController: NSObject {
5949
}
6050

6151
private extension EditMenuController {
62-
#if compiler(>=5.7)
6352
@available(iOS 16, *)
6453
private func setupEditMenuInteraction(in view: UIView) {
6554
let editMenuInteraction = UIEditMenuInteraction(delegate: self)
6655
_editMenuInteraction = editMenuInteraction
6756
view.addInteraction(editMenuInteraction)
6857
}
69-
#endif
7058

7159
private func setupMenuController() {
7260
// This is not necessary starting from iOS 16.
@@ -100,7 +88,6 @@ private extension EditMenuController {
10088
}
10189
}
10290

103-
#if compiler(>=5.7)
10491
@available(iOS 16, *)
10592
extension EditMenuController: UIEditMenuInteractionDelegate {
10693
func editMenuInteraction(_ interaction: UIEditMenuInteraction,
@@ -113,4 +100,3 @@ extension EditMenuController: UIEditMenuInteractionDelegate {
113100
}
114101
}
115102
}
116-
#endif

Sources/Runestone/TextView/Core/TextView.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,6 @@ open class TextView: UIScrollView {
564564
}
565565
/// When enabled the text view will present a menu with actions actions such as Copy and Replace after navigating to a highlighted range.
566566
public var showMenuAfterNavigatingToHighlightedRange = true
567-
#if compiler(>=5.7)
568567
/// A boolean value that enables a text view’s built-in find interaction.
569568
///
570569
/// After enabling the find interaction, use [`presentFindNavigator(showingReplace:)`](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator) on <doc:findInteraction> to present the find navigator.
@@ -586,18 +585,15 @@ open class TextView: UIScrollView {
586585
public var findInteraction: UIFindInteraction? {
587586
textSearchingHelper.findInteraction
588587
}
589-
#endif
590588

591589
private let textInputView: TextInputView
592590
private let editableTextInteraction = UITextInteraction(for: .editable)
593591
private let nonEditableTextInteraction = UITextInteraction(for: .nonEditable)
594-
#if compiler(>=5.7)
595592
@available(iOS 16.0, *)
596593
private var editMenuInteraction: UIEditMenuInteraction? {
597594
_editMenuInteraction as? UIEditMenuInteraction
598595
}
599596
private var _editMenuInteraction: Any?
600-
#endif
601597
private let tapGestureRecognizer = QuickTapGestureRecognizer()
602598
private var _inputAccessoryView: UIView?
603599
private let _inputAssistantItem = UITextInputAssistantItem()

Sources/Runestone/TextView/SearchAndReplace/UITextSearchingHelper.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import UIKit
22

33
final class UITextSearchingHelper: NSObject {
44
weak var textView: TextView?
5-
#if compiler(>=5.7)
65
var isFindInteractionEnabled = false {
76
didSet {
87
if isFindInteractionEnabled != oldValue {
@@ -17,22 +16,19 @@ final class UITextSearchingHelper: NSObject {
1716
@available(iOS 16, *)
1817
var findInteraction: UIFindInteraction? {
1918
get {
20-
// swiftlint:disable implicit_return
2119
guard let _findInteraction = _findInteraction else {
2220
return nil
2321
}
2422
guard let findInteraction = _findInteraction as? UIFindInteraction else {
2523
fatalError("Expected _findInteraction to be of type \(UIFindInteraction.self)")
2624
}
2725
return findInteraction
28-
// swiftlint:enable implicit_return
2926
}
3027
set {
3128
_findInteraction = newValue
3229
}
3330
}
3431
private var _findInteraction: Any?
35-
#endif
3632

3733
private let queue = OperationQueue()
3834
private var _textView: TextView {
@@ -54,7 +50,6 @@ final class UITextSearchingHelper: NSObject {
5450
}
5551
}
5652

57-
#if compiler(>=5.7)
5853
@available(iOS 16, *)
5954
extension UITextSearchingHelper: UITextSearching {
6055
var supportsTextReplacement: Bool {
@@ -201,4 +196,3 @@ private extension SearchQuery.MatchMethod {
201196
}
202197
}
203198
}
204-
#endif

0 commit comments

Comments
 (0)