Bump to iOS 15 deployment target and fix build issues

This commit is contained in:
Nathan Mattes 2022-12-17 20:26:20 +01:00
parent e52315f0e0
commit 1d7dc2f266
32 changed files with 74 additions and 254 deletions

View File

@ -3831,7 +3831,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INTENTS_CODEGEN_LANGUAGE = Swift;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
@ -3889,7 +3889,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INTENTS_CODEGEN_LANGUAGE = Swift;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
@ -4091,7 +4091,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INTENTS_CODEGEN_LANGUAGE = Swift;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
@ -4373,7 +4373,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INTENTS_CODEGEN_LANGUAGE = Swift;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;

View File

@ -228,11 +228,7 @@ extension StatusSection {
}
var _snapshot = NSDiffableDataSourceSnapshot<PollSection, PollItem>()
_snapshot.appendSections([.main])
if #available(iOS 15.0, *) {
statusView.pollTableViewDiffableDataSource?.applySnapshotUsingReloadData(_snapshot)
} else {
statusView.pollTableViewDiffableDataSource?.apply(_snapshot, animatingDifferences: false)
}
statusView.pollTableViewDiffableDataSource?.applySnapshotUsingReloadData(_snapshot)
}
}

View File

@ -13,11 +13,7 @@ extension UICollectionViewDiffableDataSource {
snapshot: NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
completion: (() -> Void)? = nil
) {
if #available(iOS 15.0, *) {
self.applySnapshotUsingReloadData(snapshot, completion: completion)
} else {
self.apply(snapshot, animatingDifferences: false, completion: completion)
}
self.applySnapshotUsingReloadData(snapshot, completion: completion)
}
func applySnapshot(
@ -25,16 +21,6 @@ extension UICollectionViewDiffableDataSource {
animated: Bool,
completion: (() -> Void)? = nil) {
if #available(iOS 15.0, *) {
self.apply(snapshot, animatingDifferences: animated, completion: completion)
} else {
if animated {
self.apply(snapshot, animatingDifferences: true, completion: completion)
} else {
UIView.performWithoutAnimation {
self.apply(snapshot, animatingDifferences: true, completion: completion)
}
}
}
self.apply(snapshot, animatingDifferences: animated, completion: completion)
}
}

View File

@ -13,28 +13,13 @@ extension UITableViewDiffableDataSource {
snapshot: NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
completion: (() -> Void)? = nil
) {
if #available(iOS 15.0, *) {
self.applySnapshotUsingReloadData(snapshot, completion: completion)
} else {
self.apply(snapshot, animatingDifferences: false, completion: completion)
}
self.applySnapshotUsingReloadData(snapshot, completion: completion)
}
func applySnapshot(
_ snapshot: NSDiffableDataSourceSnapshot<SectionIdentifierType, ItemIdentifierType>,
animated: Bool,
completion: (() -> Void)? = nil) {
if #available(iOS 15.0, *) {
self.apply(snapshot, animatingDifferences: animated, completion: completion)
} else {
if animated {
self.apply(snapshot, animatingDifferences: true, completion: completion)
} else {
UIView.performWithoutAnimation {
self.apply(snapshot, animatingDifferences: true, completion: completion)
}
}
}
self.apply(snapshot, animatingDifferences: animated, completion: completion)
}
}

View File

@ -131,17 +131,13 @@ extension HomeTimelineViewModel {
snapshot: NSDiffableDataSourceSnapshot<StatusSection, StatusItem>,
animatingDifferences: Bool
) async {
diffableDataSource?.apply(snapshot, animatingDifferences: animatingDifferences)
await diffableDataSource?.apply(snapshot, animatingDifferences: animatingDifferences)
}
@MainActor func updateSnapshotUsingReloadData(
snapshot: NSDiffableDataSourceSnapshot<StatusSection, StatusItem>
) {
if #available(iOS 15.0, *) {
self.diffableDataSource?.applySnapshotUsingReloadData(snapshot)
} else {
diffableDataSource?.applySnapshot(snapshot, animated: false, completion: nil)
}
self.diffableDataSource?.applySnapshotUsingReloadData(snapshot)
}
struct Difference<T> {

View File

@ -149,12 +149,7 @@ extension HomeTimelineViewModel {
}
// reconfigure item
if #available(iOS 15.0, *) {
snapshot.reconfigureItems([item])
} else {
// Fallback on earlier versions
snapshot.reloadItems([item])
}
snapshot.reconfigureItems([item])
await updateSnapshotUsingReloadData(snapshot: snapshot)
// fetch data
@ -177,15 +172,10 @@ extension HomeTimelineViewModel {
}
// reconfigure item again
if #available(iOS 15.0, *) {
snapshot.reconfigureItems([item])
} else {
// Fallback on earlier versions
snapshot.reloadItems([item])
}
snapshot.reconfigureItems([item])
await updateSnapshotUsingReloadData(snapshot: snapshot)
}
}
// MARK: - SuggestionAccountViewModelDelegate

View File

@ -111,17 +111,13 @@ extension NotificationTimelineViewModel {
snapshot: NSDiffableDataSourceSnapshot<NotificationSection, NotificationItem>,
animatingDifferences: Bool
) async {
diffableDataSource?.apply(snapshot, animatingDifferences: animatingDifferences)
await diffableDataSource?.apply(snapshot, animatingDifferences: animatingDifferences)
}
@MainActor func updateSnapshotUsingReloadData(
snapshot: NSDiffableDataSourceSnapshot<NotificationSection, NotificationItem>
) async {
if #available(iOS 15.0, *) {
await self.diffableDataSource?.applySnapshotUsingReloadData(snapshot)
} else {
diffableDataSource?.applySnapshot(snapshot, animated: false, completion: nil)
}
await self.diffableDataSource?.applySnapshotUsingReloadData(snapshot)
}
}

View File

@ -43,11 +43,7 @@ final class MastodonPickServerViewController: UIViewController, NeedsDependency
tableView.separatorStyle = .none
tableView.backgroundColor = .clear
tableView.keyboardDismissMode = .onDrag
if #available(iOS 15.0, *) {
tableView.sectionHeaderTopPadding = .leastNonzeroMagnitude
} else {
// Fallback on earlier versions
}
tableView.sectionHeaderTopPadding = .leastNonzeroMagnitude
return tableView
}()

View File

@ -55,19 +55,10 @@ struct MastodonRegisterView: View {
// Delete
if viewModel.avatarImage != nil {
Divider()
if #available(iOS 15.0, *) {
Button(role: .destructive) {
viewModel.avatarMediaMenuActionPublisher.send(.delete)
} label: {
Label(L10n.Scene.Register.Input.Avatar.delete, systemImage: "delete.left")
}
} else {
// Fallback on earlier ve rsions
Button {
viewModel.avatarMediaMenuActionPublisher.send(.delete)
} label: {
Label(L10n.Scene.Register.Input.Avatar.delete, systemImage: "delete.left")
}
Button(role: .destructive) {
viewModel.avatarMediaMenuActionPublisher.send(.delete)
} label: {
Label(L10n.Scene.Register.Input.Avatar.delete, systemImage: "delete.left")
}
}
} label: {

View File

@ -37,11 +37,7 @@ final class MastodonServerRulesViewController: UIViewController, NeedsDependency
tableView.separatorStyle = .none
tableView.backgroundColor = .clear
tableView.keyboardDismissMode = .onDrag
if #available(iOS 15.0, *) {
tableView.sectionHeaderTopPadding = 0
} else {
// Fallback on earlier versions
}
tableView.sectionHeaderTopPadding = 0
return tableView
}()

View File

@ -66,11 +66,7 @@ extension OnboardingViewControllerAppearance {
navigationItem.standardAppearance = barAppearance
navigationItem.compactAppearance = barAppearance
navigationItem.scrollEdgeAppearance = barAppearance
if #available(iOS 15.0, *) {
navigationItem.compactScrollEdgeAppearance = barAppearance
} else {
// Fallback on earlier versions
}
navigationItem.compactScrollEdgeAppearance = barAppearance
}
func setupNavigationBarBackgroundView() {

View File

@ -336,11 +336,7 @@ extension WelcomeViewController: OnboardingViewControllerAppearance {
navigationItem.standardAppearance = barAppearance
navigationItem.compactAppearance = barAppearance
navigationItem.scrollEdgeAppearance = barAppearance
if #available(iOS 15.0, *) {
navigationItem.compactScrollEdgeAppearance = barAppearance
} else {
// Fallback on earlier versions
}
navigationItem.compactScrollEdgeAppearance = barAppearance
}
}

View File

@ -27,12 +27,7 @@ extension FollowerListViewModel {
var snapshot = NSDiffableDataSourceSnapshot<UserSection, UserItem>()
snapshot.appendSections([.main])
snapshot.appendItems([.bottomLoader], toSection: .main)
if #available(iOS 15.0, *) {
diffableDataSource?.applySnapshotUsingReloadData(snapshot, completion: nil)
} else {
// Fallback on earlier versions
diffableDataSource?.apply(snapshot, animatingDifferences: false)
}
diffableDataSource?.applySnapshotUsingReloadData(snapshot, completion: nil)
userFetchedResultsController.$records
.receive(on: DispatchQueue.main)

View File

@ -28,13 +28,8 @@ extension FollowingListViewModel {
var snapshot = NSDiffableDataSourceSnapshot<UserSection, UserItem>()
snapshot.appendSections([.main])
snapshot.appendItems([.bottomLoader], toSection: .main)
if #available(iOS 15.0, *) {
diffableDataSource?.applySnapshotUsingReloadData(snapshot, completion: nil)
} else {
// Fallback on earlier versions
diffableDataSource?.apply(snapshot, animatingDifferences: false)
}
diffableDataSource?.applySnapshotUsingReloadData(snapshot)
userFetchedResultsController.$records
.receive(on: DispatchQueue.main)
.sink { [weak self] records in

View File

@ -28,13 +28,8 @@ extension UserListViewModel {
var snapshot = NSDiffableDataSourceSnapshot<UserSection, UserItem>()
snapshot.appendSections([.main])
snapshot.appendItems([.bottomLoader], toSection: .main)
if #available(iOS 15.0, *) {
diffableDataSource?.applySnapshotUsingReloadData(snapshot, completion: nil)
} else {
// Fallback on earlier versions
diffableDataSource?.apply(snapshot, animatingDifferences: false)
}
diffableDataSource?.applySnapshotUsingReloadData(snapshot)
// trigger initial loading
stateMachine.enter(UserListViewModel.State.Reloading.self)

View File

@ -47,11 +47,7 @@ class ReportStatusViewController: UIViewController, NeedsDependency, ReportViewC
tableView.backgroundColor = .clear
tableView.keyboardDismissMode = .onDrag
tableView.allowsMultipleSelection = true
if #available(iOS 15.0, *) {
tableView.sectionHeaderTopPadding = .leastNonzeroMagnitude
} else {
// Fallback on earlier versions
}
tableView.sectionHeaderTopPadding = .leastNonzeroMagnitude
return tableView
}()

View File

@ -52,11 +52,7 @@ final class ReportSupplementaryViewController: UIViewController, NeedsDependency
tableView.separatorStyle = .none
tableView.backgroundColor = .clear
tableView.keyboardDismissMode = .onDrag
if #available(iOS 15.0, *) {
tableView.sectionHeaderTopPadding = .leastNonzeroMagnitude
} else {
// Fallback on earlier versions
}
tableView.sectionHeaderTopPadding = .leastNonzeroMagnitude
return tableView
}()

View File

@ -42,11 +42,7 @@ extension ReportViewControllerAppearance {
navigationItem.standardAppearance = barAppearance
navigationItem.compactAppearance = barAppearance
navigationItem.scrollEdgeAppearance = barAppearance
if #available(iOS 15.0, *) {
navigationItem.compactScrollEdgeAppearance = barAppearance
} else {
// Fallback on earlier versions
}
navigationItem.compactScrollEdgeAppearance = barAppearance
}
func setupNavigationBarBackgroundView() {

View File

@ -135,10 +135,7 @@ extension SearchViewController {
navigationItem.standardAppearance = navigationBarAppearance
navigationItem.scrollEdgeAppearance = navigationBarAppearance
navigationItem.compactAppearance = navigationBarAppearance
if #available(iOS 15, *) {
navigationItem.compactScrollEdgeAppearance = navigationBarAppearance
}
navigationItem.compactScrollEdgeAppearance = navigationBarAppearance
}
private func setupSearchBar() {

View File

@ -54,7 +54,7 @@ extension SearchHistoryViewModel {
var snapshot = NSDiffableDataSourceSnapshot<SearchHistorySection, SearchHistoryItem>()
snapshot.appendSections([.main])
snapshot.appendItems(items, toSection: .main)
diffableDataSource.apply(snapshot, animatingDifferences: false)
await diffableDataSource.apply(snapshot, animatingDifferences: false)
} catch {
// do nothing
}

View File

@ -34,12 +34,7 @@ extension SuggestionAccountViewModel {
let items: [RecommendAccountItem] = records.map { RecommendAccountItem.account($0) }
snapshot.appendItems(items, toSection: .main)
if #available(iOS 15.0, *) {
tableViewDiffableDataSource.applySnapshotUsingReloadData(snapshot, completion: nil)
} else {
// Fallback on earlier versions
tableViewDiffableDataSource.applySnapshot(snapshot, animated: false, completion: nil)
}
tableViewDiffableDataSource.applySnapshotUsingReloadData(snapshot, completion: nil)
}
.store(in: &disposeBag)
}
@ -71,13 +66,7 @@ extension SuggestionAccountViewModel {
}
snapshot.appendItems(items, toSection: .main)
if #available(iOS 15.0, *) {
collectionViewDiffableDataSource.applySnapshotUsingReloadData(snapshot, completion: nil)
} else {
// Fallback on earlier versions
collectionViewDiffableDataSource.applySnapshot(snapshot, animated: false, completion: nil)
}
collectionViewDiffableDataSource.applySnapshotUsingReloadData(snapshot, completion: nil)
}
.store(in: &disposeBag)
}

View File

@ -154,17 +154,13 @@ extension ThreadViewModel {
snapshot: NSDiffableDataSourceSnapshot<StatusSection, StatusItem>,
animatingDifferences: Bool
) async {
diffableDataSource?.apply(snapshot, animatingDifferences: animatingDifferences)
await diffableDataSource?.apply(snapshot, animatingDifferences: animatingDifferences)
}
@MainActor func updateSnapshotUsingReloadData(
snapshot: NSDiffableDataSourceSnapshot<StatusSection, StatusItem>
) async {
if #available(iOS 15.0, *) {
await self.diffableDataSource?.applySnapshotUsingReloadData(snapshot)
} else {
diffableDataSource?.applySnapshot(snapshot, animated: false, completion: nil)
}
await self.diffableDataSource?.applySnapshotUsingReloadData(snapshot)
}
// Some UI tweaks to present replies and conversation smoothly

View File

@ -7,7 +7,7 @@ let package = Package(
name: "MastodonSDK",
defaultLocalization: "en",
platforms: [
.iOS(.v14),
.iOS(.v15),
],
products: [
.library(

View File

@ -50,43 +50,16 @@ extension NSManagedObjectContext {
extension NSManagedObjectContext {
public func perform<T>(block: @escaping () throws -> T) async throws -> T {
if #available(iOS 15.0, *) {
return try await perform(schedule: .enqueued) {
try block()
}
} else {
return try await withCheckedThrowingContinuation { continuation in
self.perform {
do {
let value = try block()
continuation.resume(returning: value)
} catch {
continuation.resume(throwing: error)
}
}
} // end return
return try await perform(schedule: .enqueued) {
try block()
}
}
public func performChanges<T>(block: @escaping () throws -> T) async throws -> T {
if #available(iOS 15.0, *) {
return try await perform(schedule: .enqueued) {
let value = try block()
try self.saveOrRollback()
return value
}
} else {
return try await withCheckedThrowingContinuation { continuation in
self.perform {
do {
let value = try block()
try self.saveOrRollback()
continuation.resume(returning: value)
} catch {
continuation.resume(throwing: error)
}
}
} // end return
return try await perform(schedule: .enqueued) {
let value = try block()
try self.saveOrRollback()
return value
}
} // end func
}

View File

@ -52,9 +52,7 @@ extension ThemeService {
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().compactAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
if #available(iOS 15.0, *) {
UINavigationBar.appearance().compactScrollEdgeAppearance = appearance
}
UINavigationBar.appearance().compactScrollEdgeAppearance = appearance
// set tab bar appearance
let tabBarAppearance = UITabBarAppearance()
@ -76,11 +74,7 @@ extension ThemeService {
tabBarAppearance.backgroundColor = theme.tabBarBackgroundColor
tabBarAppearance.selectionIndicatorTintColor = ThemeService.tintColor
UITabBar.appearance().standardAppearance = tabBarAppearance
if #available(iOS 15.0, *) {
UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
} else {
// Fallback on earlier versions
}
UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
UITabBar.appearance().barTintColor = theme.tabBarBackgroundColor
// set table view cell appearance

View File

@ -48,14 +48,10 @@ extension Date {
if earlierDate.timeIntervalSince(latestDate) < -(7 * 24 * 60 * 60) {
let currentYear = Date.calendar.dateComponents([.year], from: Date())
let earlierDateYear = Date.calendar.dateComponents([.year], from: earlierDate)
if #available(iOS 15.0, *) {
if currentYear.year! > earlierDateYear.year! {
return earlierDate.formatted(.dateTime.year().month(.abbreviated).day())
} else {
return earlierDate.formatted(.dateTime.month(.abbreviated).day())
}
if currentYear.year! > earlierDateYear.year! {
return earlierDate.formatted(.dateTime.year().month(.abbreviated).day())
} else {
return Date.abbreviatedDateFormatter.string(from: earlierDate)
return earlierDate.formatted(.dateTime.month(.abbreviated).day())
}
} else {
return Date.relativeTimestampFormatter.localizedString(for: earlierDate, relativeTo: latestDate)

View File

@ -15,19 +15,17 @@ extension MetaTextView {
// fix #660
// https://github.com/mastodon/mastodon-ios/issues/660
if #available(iOS 15.0, *) {
var nextResponder = self.next;
// Force the event to bubble through ALL responders
// This is a workaround as somewhere down the chain the paste event gets eaten
while (nextResponder != nil) {
if let nextResponder = nextResponder {
if (nextResponder.responds(to: #selector(UIResponderStandardEditActions.paste(_:)))) {
nextResponder.perform(#selector(UIResponderStandardEditActions.paste(_:)), with: sender)
}
var nextResponder = self.next;
// Force the event to bubble through ALL responders
// This is a workaround as somewhere down the chain the paste event gets eaten
while (nextResponder != nil) {
if let nextResponder = nextResponder {
if (nextResponder.responds(to: #selector(UIResponderStandardEditActions.paste(_:)))) {
nextResponder.perform(#selector(UIResponderStandardEditActions.paste(_:)), with: sender)
}
nextResponder = nextResponder?.next;
}
} // end if
nextResponder = nextResponder?.next;
}
}
}

View File

@ -33,21 +33,15 @@ public final class StatusCardControl: UIControl {
private let titleLabel = UILabel()
private let linkLabel = UILabel()
private lazy var showEmbedButton: UIButton = {
if #available(iOS 15.0, *) {
var configuration = UIButton.Configuration.gray()
configuration.background.visualEffect = UIBlurEffect(style: .systemUltraThinMaterial)
configuration.baseBackgroundColor = .clear
configuration.cornerStyle = .capsule
configuration.buttonSize = .large
configuration.title = L10n.Common.Controls.Status.loadEmbed
configuration.image = UIImage(systemName: "play.fill")
configuration.imagePadding = 12
return UIButton(configuration: configuration, primaryAction: UIAction { [weak self] _ in
self?.showWebView()
})
}
return UIButton(type: .system, primaryAction: UIAction { [weak self] _ in
var configuration = UIButton.Configuration.gray()
configuration.background.visualEffect = UIBlurEffect(style: .systemUltraThinMaterial)
configuration.baseBackgroundColor = .clear
configuration.cornerStyle = .capsule
configuration.buttonSize = .large
configuration.title = L10n.Common.Controls.Status.loadEmbed
configuration.image = UIImage(systemName: "play.fill")
configuration.imagePadding = 12
return UIButton(configuration: configuration, primaryAction: UIAction { [weak self] _ in
self?.showWebView()
})
}()
@ -85,10 +79,7 @@ public final class StatusCardControl: UIControl {
layer.cornerCurve = .continuous
layer.cornerRadius = 10
if #available(iOS 15, *) {
maximumContentSizeCategory = .accessibilityLarge
}
maximumContentSizeCategory = .accessibilityLarge
highlightView.backgroundColor = UIColor.label.withAlphaComponent(0.1)
highlightView.isHidden = true

View File

@ -419,12 +419,7 @@ extension StatusView.ViewModel {
var snapshot = NSDiffableDataSourceSnapshot<PollSection, PollItem>()
snapshot.appendSections([.main])
snapshot.appendItems(items, toSection: .main)
if #available(iOS 15.0, *) {
statusView.pollTableViewDiffableDataSource?.applySnapshotUsingReloadData(snapshot)
} else {
// Fallback on earlier versions
statusView.pollTableViewDiffableDataSource?.apply(snapshot, animatingDifferences: false)
}
statusView.pollTableViewDiffableDataSource?.applySnapshotUsingReloadData(snapshot)
statusView.pollTableViewHeightLayoutConstraint.constant = CGFloat(items.count) * PollOptionTableViewCell.height
statusView.setPollDisplay()

View File

@ -252,12 +252,7 @@ public final class StatusView: UIView {
authorView.avatarButton.avatarImageView.cancelTask()
if var snapshot = pollTableViewDiffableDataSource?.snapshot() {
snapshot.deleteAllItems()
if #available(iOS 15.0, *) {
pollTableViewDiffableDataSource?.applySnapshotUsingReloadData(snapshot)
} else {
// Fallback on earlier versions
pollTableViewDiffableDataSource?.apply(snapshot, animatingDifferences: false)
}
pollTableViewDiffableDataSource?.applySnapshotUsingReloadData(snapshot)
}
setHeaderDisplay(isDisplay: false)

View File

@ -46,7 +46,6 @@ extension MastodonTests {
wait(for: [expectation], timeout: 10)
}
@available(iOS 15.0, *)
func testConnectOnion() async throws {
let request = URLRequest(
url: URL(string: "http://a232ncr7jexk2chvubaq2v6qdizbocllqap7mnn7w7vrdutyvu32jeyd.onion/@k0gen")!,

View File

@ -1,5 +1,5 @@
source 'https://cdn.cocoapods.org/'
platform :ios, '14.0'
platform :ios, '15.0'
target 'Mastodon' do
# Comment the next line if you don't want to use dynamic frameworks