From d859552575c771c69c002385d256493c8b6c883e Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 24 Jan 2023 17:22:25 -0500 Subject: [PATCH] Bump deployment target to iOS 16, use URL.ParseStrategy --- Fervor/Package.swift | 2 +- Fervor/Sources/Fervor/Item.swift | 13 ++++++++++++- Persistence/Package.swift | 2 +- Reader.xcodeproj/project.pbxproj | 4 ++-- Reader/AppDelegate.swift | 26 -------------------------- 5 files changed, 16 insertions(+), 31 deletions(-) diff --git a/Fervor/Package.swift b/Fervor/Package.swift index 373fdb0..39a5642 100644 --- a/Fervor/Package.swift +++ b/Fervor/Package.swift @@ -6,7 +6,7 @@ import PackageDescription let package = Package( name: "Fervor", platforms: [ - .iOS(.v15), + .iOS(.v16), ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. diff --git a/Fervor/Sources/Fervor/Item.swift b/Fervor/Sources/Fervor/Item.swift index 26f1e85..9760d70 100644 --- a/Fervor/Sources/Fervor/Item.swift +++ b/Fervor/Sources/Fervor/Item.swift @@ -8,6 +8,16 @@ import Foundation public struct Item: Decodable, Sendable { + private static let urlParseStrategy = URL.ParseStrategy() + .scheme(.defaultValue("https")) + .user(.optional) + .password(.optional) + .host(.required) + .port(.defaultValue(8080)) + .path(.optional) + .query(.optional) + .fragment(.optional) + public let id: FervorID public let feedID: FervorID public let title: String? @@ -31,7 +41,8 @@ public struct Item: Decodable, Sendable { self.createdAt = try container.decodeIfPresent(Date.self, forKey: .createdAt) self.content = try container.decodeIfPresent(String.self, forKey: .content) self.summary = try container.decodeIfPresent(String.self, forKey: .summary) - self.url = try container.decode(URL.self, forKey: .url) + let urlStr = try container.decode(String.self, forKey: .url) + self.url = try Self.urlParseStrategy.parse(urlStr) self.serviceURL = try container.decodeIfPresent(URL.self, forKey: .serviceURL) self.read = try container.decodeIfPresent(Bool.self, forKey: .read) } diff --git a/Persistence/Package.swift b/Persistence/Package.swift index b844ebd..e76b1a5 100644 --- a/Persistence/Package.swift +++ b/Persistence/Package.swift @@ -6,7 +6,7 @@ import PackageDescription let package = Package( name: "Persistence", platforms: [ - .iOS(.v15), + .iOS(.v16), ], products: [ // Products define the executables and libraries a package produces, and make them visible to other packages. diff --git a/Reader.xcodeproj/project.pbxproj b/Reader.xcodeproj/project.pbxproj index 244dc80..fdc25d4 100644 --- a/Reader.xcodeproj/project.pbxproj +++ b/Reader.xcodeproj/project.pbxproj @@ -904,7 +904,7 @@ INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", @@ -945,7 +945,7 @@ INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - IPHONEOS_DEPLOYMENT_TARGET = 15.0; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", diff --git a/Reader/AppDelegate.swift b/Reader/AppDelegate.swift index 3d5c677..4940b82 100644 --- a/Reader/AppDelegate.swift +++ b/Reader/AppDelegate.swift @@ -24,8 +24,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { LocalData.migrateIfNecessary() - swizzleWKWebView() - Preferences.shared.objectWillChange .debounce(for: .milliseconds(250), scheduler: RunLoop.main) .sink { _ in @@ -133,30 +131,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate { } } - // this workaround is no longer necessary (in fact, it causes a stack overflow) post-iOS 15.4 because of: - // https://github.com/WebKit/WebKit/commit/1dbd34cf01d8b5aedcb8820b13cb6553ed60e8ed - @available(iOS, obsoleted: 15.4) - private func swizzleWKWebView() { - if #available(iOS 15.4, *) { - } else { - let selector = Selector(("_updateScrollViewBackground")) - var originalIMP: IMP? - let imp = imp_implementationWithBlock({ (self: WKWebView) in - if let originalIMP = originalIMP { - let original = unsafeBitCast(originalIMP, to: (@convention(c) (WKWebView, Selector) -> Void).self) - original(self, selector) - } - - self.scrollView.indicatorStyle = .default - - } as (@convention(block) (WKWebView) -> Void)) - originalIMP = class_replaceMethod(WKWebView.self, selector, imp, "v@:") - if originalIMP == nil { - os_log(.error, "Missing originalIMP for -[WKWebView _updateScrollViewBackground], did WebKit change?") - } - } - } - @objc private func showPreferences() { let existing = UIApplication.shared.connectedScenes.first { $0.session.configuration.name == "prefs"