From 1c708732f29800ca274b968af69a9f7eee2d16b2 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 5 Jul 2020 23:00:57 -0400 Subject: [PATCH] Exclude iOS 14-specific code from compilation on Xcode 11 to allow building for TestFlight --- Tusker.xcodeproj/project.pbxproj | 2 ++ Tusker/SceneDelegate.swift | 4 ++++ Tusker/Screens/Compose/ComposeDrawingViewController.swift | 4 ++++ Tusker/Screens/Main/MainSidebarViewController.swift | 2 ++ Tusker/Screens/Main/MainSplitViewController.swift | 2 ++ Tusker/Screens/Utilities/Previewing.swift | 2 ++ Tusker/Views/Profile Header/ProfileHeaderView.swift | 2 ++ Tusker/Views/Status/BaseStatusTableViewCell.swift | 4 ++++ Tusker/Views/VisualEffectImageButton.swift | 4 ++++ 9 files changed, 26 insertions(+) diff --git a/Tusker.xcodeproj/project.pbxproj b/Tusker.xcodeproj/project.pbxproj index 7eb72767..a2218bb5 100644 --- a/Tusker.xcodeproj/project.pbxproj +++ b/Tusker.xcodeproj/project.pbxproj @@ -2184,6 +2184,7 @@ ); MARKETING_VERSION = 2020.1; OTHER_LDFLAGS = ""; + "OTHER_SWIFT_FLAGS[sdk=iphone*14*]" = "$(inherited) -D SDK_IOS_14"; PRODUCT_BUNDLE_IDENTIFIER = space.vaccor.Tusker; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; @@ -2211,6 +2212,7 @@ "@executable_path/Frameworks", ); MARKETING_VERSION = 2020.1; + "OTHER_SWIFT_FLAGS[sdk=iphone*14*]" = "$(inherited) -D SDK_IOS_14"; PRODUCT_BUNDLE_IDENTIFIER = space.vaccor.Tusker; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; diff --git a/Tusker/SceneDelegate.swift b/Tusker/SceneDelegate.swift index 27eccb6d..1cd872f9 100644 --- a/Tusker/SceneDelegate.swift +++ b/Tusker/SceneDelegate.swift @@ -158,11 +158,15 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { mastodonController.getOwnInstance() let rootController: UIViewController + #if SDK_IOS_14 if #available(iOS 14.0, *) { rootController = MainSplitViewController(mastodonController: mastodonController) } else { rootController = MainTabBarViewController(mastodonController: mastodonController) } + #else + rootController = MainTabBarViewController(mastodonController: mastodonController) + #endif window!.rootViewController = rootController } diff --git a/Tusker/Screens/Compose/ComposeDrawingViewController.swift b/Tusker/Screens/Compose/ComposeDrawingViewController.swift index 39251a40..b9058a75 100644 --- a/Tusker/Screens/Compose/ComposeDrawingViewController.swift +++ b/Tusker/Screens/Compose/ComposeDrawingViewController.swift @@ -58,11 +58,15 @@ class ComposeDrawingViewController: UIViewController { canvasView.drawing = initialDrawing } canvasView.delegate = self + #if SDK_IOS_14 if #available(iOS 14.0, *) { canvasView.drawingPolicy = .anyInput } else { canvasView.allowsFingerDrawing = true } + #else + canvasView.allowsFingerDrawing = true + #endif canvasView.minimumZoomScale = 0.5 canvasView.maximumZoomScale = 2 canvasView.backgroundColor = .systemBackground diff --git a/Tusker/Screens/Main/MainSidebarViewController.swift b/Tusker/Screens/Main/MainSidebarViewController.swift index 5294637d..acd32ba6 100644 --- a/Tusker/Screens/Main/MainSidebarViewController.swift +++ b/Tusker/Screens/Main/MainSidebarViewController.swift @@ -9,6 +9,7 @@ import UIKit import Pachyderm +#if SDK_IOS_14 @available(iOS 14.0, *) protocol MainSidebarViewControllerDelegate: class { func sidebarRequestPresentCompose(_ sidebarViewController: MainSidebarViewController) @@ -379,3 +380,4 @@ extension MainSidebarViewController: InstanceTimelineViewControllerDelegate { dismiss(animated: true) } } +#endif diff --git a/Tusker/Screens/Main/MainSplitViewController.swift b/Tusker/Screens/Main/MainSplitViewController.swift index 8a4644f1..5ce25b2e 100644 --- a/Tusker/Screens/Main/MainSplitViewController.swift +++ b/Tusker/Screens/Main/MainSplitViewController.swift @@ -8,6 +8,7 @@ import UIKit +#if SDK_IOS_14 @available(iOS 14.0, *) class MainSplitViewController: UISplitViewController { @@ -319,3 +320,4 @@ extension MainSplitViewController: TuskerRootViewController { } } } +#endif diff --git a/Tusker/Screens/Utilities/Previewing.swift b/Tusker/Screens/Utilities/Previewing.swift index f91d8f45..8db90ebe 100644 --- a/Tusker/Screens/Utilities/Previewing.swift +++ b/Tusker/Screens/Utilities/Previewing.swift @@ -44,6 +44,7 @@ extension MenuPreviewProvider { ] // todo: handle pre-iOS 14 + #if SDK_IOS_14 if accountID != mastodonController.account.id, #available(iOS 14.0, *) { actionsSection.append(UIDeferredMenuElement({ (elementHandler) in @@ -69,6 +70,7 @@ extension MenuPreviewProvider { } })) } + #endif let shareSection = [ openInSafariAction(url: account.url), diff --git a/Tusker/Views/Profile Header/ProfileHeaderView.swift b/Tusker/Views/Profile Header/ProfileHeaderView.swift index 651f767c..c0ce4bb5 100644 --- a/Tusker/Views/Profile Header/ProfileHeaderView.swift +++ b/Tusker/Views/Profile Header/ProfileHeaderView.swift @@ -82,10 +82,12 @@ class ProfileHeaderView: UIView { if #available(iOS 13.4, *) { moreButton.addInteraction(UIPointerInteraction(delegate: self)) } + #if SDK_IOS_14 if #available(iOS 14.0, *) { moreButton.showsMenuAsPrimaryAction = true moreButton.isContextMenuInteractionEnabled = true } + #endif } func updateUI(for accountID: String) { diff --git a/Tusker/Views/Status/BaseStatusTableViewCell.swift b/Tusker/Views/Status/BaseStatusTableViewCell.swift index 41d544d3..ee3e567b 100644 --- a/Tusker/Views/Status/BaseStatusTableViewCell.swift +++ b/Tusker/Views/Status/BaseStatusTableViewCell.swift @@ -87,9 +87,11 @@ class BaseStatusTableViewCell: UITableViewCell { accessibilityElements = [displayNameLabel!, contentWarningLabel!, collapseButton!, contentTextView!, attachmentsView!] attachmentsView.isAccessibilityElement = true + #if SDK_IOS_14 if #available(iOS 14.0, *) { moreButton.showsMenuAsPrimaryAction = true } + #endif NotificationCenter.default.addObserver(self, selector: #selector(preferencesChanged), name: .preferencesChanged, object: nil) } @@ -199,10 +201,12 @@ class BaseStatusTableViewCell: UITableViewCell { reblogButton.accessibilityLabel = NSLocalizedString("Reblog", comment: "reblog button accessibility label") } + #if SDK_IOS_14 if #available(iOS 14.0, *) { // keep menu in sync with changed states e.g. bookmarked, muted moreButton.menu = UIMenu(title: "", image: nil, identifier: nil, options: [], children: actionsForStatus(statusID: statusID, sourceView: moreButton)) } + #endif } func updateUI(account: AccountMO) { diff --git a/Tusker/Views/VisualEffectImageButton.swift b/Tusker/Views/VisualEffectImageButton.swift index 9b04a212..c56706b9 100644 --- a/Tusker/Views/VisualEffectImageButton.swift +++ b/Tusker/Views/VisualEffectImageButton.swift @@ -52,7 +52,9 @@ class VisualEffectImageButton: UIControl { imageView.bottomAnchor.constraint(equalTo: vibrancyView.bottomAnchor, constant: -2), ]) + #if SDK_IOS_14 addInteraction(UIContextMenuInteraction(delegate: self)) + #endif addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(onTap))) } @@ -61,10 +63,12 @@ class VisualEffectImageButton: UIControl { sendActions(for: .touchUpInside) } + #if SDK_IOS_14 override func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? { guard let menu = menu else { return nil } return UIContextMenuConfiguration(identifier: nil, previewProvider: nil) { (_) -> UIMenu? in return menu } } + #endif }